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
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:
If you dont want the validation for the button then you can set the CausesValidation property to false
To make validation all false, u have to make cause validation property set to false.Ex: in cancel button's click event.
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;
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 Kumar Arora
Site Coordinator - DNS
My blog - http://gaurav-arora.com
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
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.