Del via


How to: Disable Validation for ASP.NET Server Controls

You might want to bypass validation under certain circumstances. For example, you might have a page in which users should be able to post even if they did not fill out all the validated fields correctly. You can set an ASP.NET server control to bypass validation on both the server and the client, or just on the client.

Security noteSecurity Note:

By default, ASP.NET Web pages perform request validation to ensure that user input does not include script or HTML elements. You can disable this feature explicitly. For more information, see Script Exploits.

You can also disable a validation control so that it is not rendered to the page at all and no validation takes place using that control.

If you want to perform validation on the server but not on the client, you can set an individual validation control to not emit client-side script. This is useful if dynamic updating on the client creates problems with the layout of the page, or if you want to execute some server code before validation takes place.

To disable validation in a specific control

  • Set the control's CausesValidation property to false.

    The following example shows how you can create a Cancel button that bypasses a validation check:

    <asp:Button id="Button1" runat="server"
      Text="Cancel" CausesValidation="False">
    </asp:Button>
    
    <asp:Button id="Button1" runat="server"
      Text="Cancel" CausesValidation="False">
    </asp:Button>
    

To disable a validation control

  • Set the validation control's Enabled property to false.

To disable client-side validation

  • Set the validation control's EnableClientScript property to false.

See Also

Concepts

Client-Side Validation for ASP.NET Server Controls

Reference

Validating User Input in ASP.NET Web Pages