RequiredFieldValidator and Cancel Button

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
 
K

Ken Cox [Microsoft MVP]

Is the Cancel button set to CausesValidation="False"?

<asp:Button id="Button2" runat="server" Text="Cancel"
CausesValidation="False"></asp:Button></P>
 
N

Nicole Calinoiu

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';">
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top