RequiredFieldValidator and Cancel Button

  • Thread starter Thread starter Mvk
  • Start date Start date
M

Mvk

Hi;

I have a simple aspx form. I have put a textbox and 2 buttons on it. The
textbox is linked to a requiredfieldvalidator.

Click on button 1 (= ok button) = Store value in textbox in database.
Click on button 2 (= cancel button) = Redirect with
Response.Redirect("AnotherPage.aspx")

Now I have the following problem. When I click on the "Cancel"-button the
the browser is not being redirected to "AnotherPage.aspx" but instead the
RequiredFieldValidator is complaining...

What I want is: When pressing on the cancel-button the browser does not have
to do the RequiredField check on the textbox!

Any Idea ?

Regards!
MVK
 
Is the Cancel button set to CausesValidation="False"?

<asp:Button id="Button2" runat="server" Text="Cancel"
CausesValidation="False"></asp:Button></P>
 
Do you really need to perform a server round-trip for your redirection? If
not, why not simply redirect on the client? e.g. (instead of your current
cancel button):

<input type="button" value="Cancel"
onclick="window.location.href='AnotherPage.aspx';">
 
Back
Top