ASP Hosting sale!
Double disk space and transfer for FREE!
Limited time offer! Act Now!

aspdev | articles | tutorials | forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ASP.NET Cancel button is triggering validation

 
Post new topic   Reply to topic    ASPdev.org Forum Index -> .NET Programming (ASP.NET, VB.NET, C#)
View previous topic :: View next topic  
Author Message
Stacy



Joined: 12 Oct 2004
Posts: 9

PostPosted: Mon Nov 08, 2004 10:00 am    Post subject: ASP.NET Cancel button is triggering validation Reply with quote

I have a form in ASP.NET page, and this form is used for user's registration. I have 2 buttons Submit and Cancel, bot ASP.NET buttons with runat=server attribute. I also have ASP.NET validators controls, validating various fields in my form, and I have enabled the client-side validation. When I click the Submit button, everything works fine, but if I click the Cancel button (it just redirects to the home page) I see the validators error messages and the redirect doesn't work.

How do I tell my ASP.NET not to run the validation, when the Cancel button has been clicked?

I hope this makes sense.



Thanks,

Stacy
Back to top
View user's profile Send private message
administrator
Site Admin


Joined: 01 Oct 2004
Posts: 183

PostPosted: Mon Nov 08, 2004 12:02 pm    Post subject: Reply with quote

Hey Stacy,

I know what you mean. You need to set the control's CausesValidation property to false, and this way your Cancel button will not not perform a validation check:

Code:

<asp:Button id="CancelButton" runat="server"
   Text="Cancel" CausesValidation="False">
</asp:Button>




Cheers,
_________________
Peter
ASP & ASP.NET Articles and Tutorials
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    ASPdev.org Forum Index -> .NET Programming (ASP.NET, VB.NET, C#) All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group

SQL Tutorial