You must Sign In to post a response.
  • Category: ASP.NET

    Use of causesValidation property for controls

    Hi friends,

    What is the use of CausesValidation property which is available for controls?

    if we set it to true what will happen and if not what will happen?

    Thanks in Advance
  • #340678
    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
    If you dont want the validation for the button then you can set the CausesValidation property to false

  • #340682
    To make validation all false, u have to make cause validation property set to false.Ex: in cancel button's click event.

  • #340702
    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

    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 -

  • #340800
    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:

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

    Keep moving Forward

  • #341033
    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.

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.