Forums » .NET » ASP.NET »

Use of causesValidation property for asp.net controls


Posted Date: 27 Jan 2009      Posted By:: Lakshmi Profile photo    Member Level: Gold    Member Rank: 126     Points: 1   Responses: 7



Hi friends,


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




Responses

#340678    Author: venkatesan.M      Member Level: Gold      Member Rank: 30     Date: 27/Jan/2009   Rating: 2 out of 52 out of 5     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"

Regards,
M.Venkatesan.

For Interview Question and Answers:
http://dotnet-interview-qa.blogspot.com

http://venkatdotnetexperiments.wordpress.com


 
#340680    Author: moturi       Member Level: Gold      Member Rank: 2219     Date: 27/Jan/2009   Rating: 2 out of 52 out of 5     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: 2 out of 52 out of 5     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: 2 out of 52 out of 5     Points: 3

Hi !

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 Arora      Member Level: Gold      Member Rank: 33     Date: 27/Jan/2009   Rating: 2 out of 52 out of 5     Points: 4

Hi,

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: 615     Date: 27/Jan/2009   Rating: 2 out of 52 out of 5     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.
Syntax

<asp:Button CausesValidation="TRUE|FALSE" runat="server" />


Example

The following example removes validation when a button is clicked:

<form runat="server">
<asp:Button id="button1" runat="server"
CausesValidation="FALSE" Text="Cancel" />
</form>

Keep moving Forward


 
#341033    Author: Nisar      Member Level: Gold      Member Rank: 68     Date: 28/Jan/2009   Rating: 2 out of 52 out of 5     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.

_______________________________
Nisar Ahmad
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.


 
Post Reply

 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.



Next : Difference between Response.Redirect () and Server.Transfer()
Previous : code project for tabcontrols asp with c#
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages

Subscribe to Subscribers
Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Talk to Webmaster Tony John

Online Members

harsha
More...
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India