Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Expertise: Beginner
Feb 22, 2005



Application Security Testing: An Integral Part of DevOps

Use CausesValidation to Prevent Unwanted Validation Checks

Validator controls automatically trigger validation checks for every postback—irrespective of whether you need validation or not. To prevent this, set CausesValidation="False" for the control for which you do not need validation. The code below will help illustrate:

		<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
		<meta name="CODE_LANGUAGE" Content="C#">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
		<form id="Form1" method="post" runat="server">
			<asp:Label id="Label1" runat="server">Name</asp:Label>
			<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
			<asp:Button id="Button1" runat="server" Text="Save"></asp:Button>
			<asp:Button id="Button2" runat="server" Text="SomeOtherInfo"
			<asp:RequiredFieldValidator id="RequiredFieldValidator1"
runat="server" ErrorMessage="User Name is required"
			<asp:Label id="Label2" runat="server">Label</asp:Label>
If you simply drop two buttons on the form, clicking either button triggers validation by default. But because you don't need a validation check when you hit Button2, setting CausesValidation="False" in the Button2 control will do the trick.

Jaya Nehru Kumar
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date