set CausesValidation = false - Validation Control and Web page navigation

Q.  There is a button on page name cancel and it should bypass validation when cancel button is clicked. What will you do?
- Published on 24 Jul 15

a. set CausesValidation = false
b. set RemoveValidation=true
c. set cancel=true
d. None of the above

ANSWER: set CausesValidation = false
 

    Discussion

  • Shiva   -Posted on 14 Sep 15
    If you set CausesValidation = false, then clicking the button bypasses any validation in the page. Button, LinkButton, and ImageButton control having CausesValidation property.
    Example:
    <asp:Button
    id=”btnCancel”
    Text=”Cancel”
    OnClick=”btnCancel_Click”
    CausesValidation=”false”
    Runat=”server” />

Post your comment / Share knowledge


Enter the code shown above:
 
(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)