ASP.NET 2.0 button CausesValidation=false

Thanks to my colleague. I did not know until today. For example you have 1 RequiredFieldValidator for your textbox. Assuming there is no value in this textbox, but you want to press the close button. By default you can’t as it will prompt you a message in the ValidationSummary to enter this value. So when you set the property of the button CausesValidation=false, it will ignore the validation.

 

<asp:Button ID="btnClose" CausesValidation=false runat="server" Text="Close" Width="64px" CssClass="buttonStyle" OnClick="btnClose_Click" />

 

Cool. Save my day J

Published Tuesday, December 12, 2006 7:31 PM by chuawenching