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?
Well you can simple use the Enabled="false" property of RequiredFieldValidator . Your markup would look something like this based on your Question.
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.
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.
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.
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" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With