Forums » .NET » ASP.NET »
Use of causesValidation property for asp.net controls
Posted Date: 27 Jan 2009 Posted By:: Lakshmi Member Level: Gold Member Rank: 123 Points: 1
What is the use of CausesValidation property which is available for asp.net controls?
if we set it to true what will happen and if not what will happen?
Thanks in Advance
|#340678 Author: venkatesan.M Member Level: Gold Member Rank: 30 Date: 27/Jan/2009 Rating: Points: 2|
To prevent validation to occur on the click of the Cancel button, set the ‘CausesValidation’ property to false
<asp:Button ID="btnCancel" Runat="server" CausesValidation="False" Text="Cancel" />
Suppose if u want a validation set CauseVAlidation="True"
For Interview Question and Answers:
|#340680 Author: moturi Member Level: Gold Member Rank: 2243 Date: 27/Jan/2009 Rating: Points: 1|
If you dont want the validation for the button then you can set the CausesValidation property to false
|#340682 Author: soubhagya kumar sahu Member Level: Bronze Member Rank: 0 Date: 27/Jan/2009 Rating: Points: 1|
To make validation all false, u have to make cause validation property set to false.Ex: in cancel button's click event.
|#340702 Author: seenu Member Level: Gold Member Rank: 333 Date: 27/Jan/2009 Rating: Points: 3|
if cause validation=true;
incause delete button u set the alert msg by then click save button open the deletebutton alert msg.....
e.g : alert msg
btnDelete.Attributes.Add("onclick","return confirm('Are you sure you want to delete this record?');");
To avoid this problem set remaining button cause validation=false;
|#340766 Author: Gaurav Kumar Arora Member Level: Gold Member Rank: 33 Date: 27/Jan/2009 Rating: Points: 4|
In simple words causevalidation=true tells that when the same button is pressed/clicked then all validators should be true.
In other words if you have set causevalidation=true on a Button then whenever you clicked the button or whenever the click event if fire of that button the all validations checkd once and page processed if they return true else generate validation error(s).
Hope the above is okie for you.
In above replies you already went through the syntaxes.
Best of luck!
Thanks & regards,
Gaurav Arora - Lead Editor
My blog - http://gaurav-arora.com
|#340800 Author: jeya sakthi vel murugan Member Level: Gold Member Rank: 617 Date: 27/Jan/2009 Rating: Points: 4|
Definition and Usage
The CausesValidation property specifies if a page is validated when a Button control is clicked.
Page validation is performed when a button is clicked by default.
This property is mostly used to prevent validation when a cancel or reset button is clicked.
<asp:Button CausesValidation="TRUE|FALSE" runat="server" />
The following example removes validation when a button is clicked:
<asp:Button id="button1" runat="server"
CausesValidation="FALSE" Text="Cancel" />
Keep moving Forward
|#341033 Author: Nisar Member Level: Gold Member Rank: 68 Date: 28/Jan/2009 Rating: Points: 2|
causesvalidation false property is used when you don't want to validate the control,
For example if you want set required field validation on textbox, but if you make textbox causesvalidation property false then required field validation doesn't work.
DotNetSpider MVM, Badge of Appreciation Award – 2010
Greatness Can't be achieved by doing big things, If you really want to be great, Do small things in Great way.
| ||This thread is locked for new responses. Please post your comments and questions as a separate thread.|
If required, refer to the URL of this page in your new post.
Active MembersTodayLast 7 Daysmore...
Talk to Webmaster Tony John