Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn required field validator off when selecting cancel button

I have a problem where my page has a required field validator, but I also want to use a 'cancel' button which will take the user back to the menu page using response.redirect("default.aspx");

Problem is the field validator keeps firing when you click the cancel button. How do you turn this off so the user can return to the menu page?

like image 796
wubblyjuggly Avatar asked Aug 09 '13 09:08

wubblyjuggly


People also ask

How do I turn off required field validator?

Well you can simple use the Enabled="false" property of RequiredFieldValidator . Your markup would look something like this based on your Question.

What is enable or disable required field validator in asp net?

Use ValidatorEnable function from the Asp.net javacsript Script Library to Enable/Disable the validators on client side. Sometimes you may need to enable/disable validators on client side. you can easily do this using ValidatorEnable function in the Asp.net javacsript Script Library.

Why do we need required field validator?

ASP.NET RequiredFieldValidator Control This validator is used to make an input control required. It will throw an error if user leaves input control empty. It is used to mandate form control required and restrict the user to provide data.

What is required validator?

Requirements validation is the process of checking that requirements defined for development, define the system that the customer really wants. To check issues related to requirements, we perform requirements validation.


1 Answers

Just add CausesValidation="false" to your button definition and it won't raise any validators:

<asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="false" />
like image 96
gzaxx Avatar answered Oct 21 '22 10:10

gzaxx