asp.net.ph

Skip Navigation Links

Disabling Validation at Run Time

ASP.NET Web Forms   Web Forms Server Controls   Web Forms Validation


At times, you might want to disable validation. In server code, you can disable server-side validation for individual controls.

You can manipulate client-side validation in two ways:

  • Permanently disable it. This is useful if you want to ensure that there is no client-side validation even in browsers that support DHTML.
  • Bypass client-side validation when the page is submitted. By default, if client validation is in effect, the page cannot be submitted to the server until all validation errors are resolved. Sometimes, however, you want to override errors. For example, in a multi-part page, it might be possible for a user to fix an entry error on the subsequent page.

To disable validation in server code

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

    If this property is set to false, the validation control will not be rendered to the page at all, and no validation will take place using that control.


To disable client-side validation permanently

  • In HTML view, add the attribute clienttarget=downlevel to the Page directive at the top of your Web Forms page. The resulting directive might look like this:
<%@ Page Language="VB" codebehind="WebForm1.vb"
   Inherits="MyProj.WebForm1" clienttarget=downlevel %>

NOTE: Disabling client validation this way also disables all other client-side functionality for server controls. For example, font and color information will be rendered in a <FONT> tag rather than as style attributes.

To bypass client-side validation at submit

  • In client script, set the Page_ValidationActive variable to false.

    The following example shows how you can create a Cancel button that disables the client-side check before a submit:

<input type=image runat=server  Value="Cancel" 
   onclick="Page_ValidationActive=false;"
   onserverclick=cmdCancel_Click >
See Also

Data Entry Validation ( Client-Side )



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note