IT Community - Software Programming, Web Development and Technical Support

How you Disable Form Validation When Using ASP.NET Web Controls?

This is a discussion on How you Disable Form Validation When Using ASP.NET Web Controls? within the ASP and ASP.NET Programming forums, part of the Web Development category; How you Disable Form Validation When Using ASP.NET Web Controls?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > ASP and ASP.NET Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-24-2007, 12:39 AM
Archer Archer is offline
D-Web Programmer
 
Join Date: Jun 2007
Posts: 52
Archer is on a distinguished road
Question How you Disable Form Validation When Using ASP.NET Web Controls?

How you Disable Form Validation When Using ASP.NET Web Controls?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-24-2007, 12:42 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 633
oxygen is on a distinguished road
Default Re: How you Disable Form Validation When Using ASP.NET Web Controls?

The following is a simplified description of the process that happens when a validation control is used on a page.
1. When a page containing validation controls is requested, the user's browser type and version is evaluated to determine if client-side validation routines should be used.
2. If the browser supports client-side validation, the page loads with the appropriate routines being called from the validation controls. This is handled through a JScript® include file.
3. When the user moves between controls on a client-side validated form after changing a control's value, the validation events for the control that lost the focus are fired and appropriate error messages (if any) are displayed.
4. If the user generates a form submit on a client-side validated form, the entire form is evaluated for any validation controls that are not valid. If even one control is not valid, the form will not be submitted.
5. When the form is posted back to the server through a postback event, it is evaluated for validity on the server. This occurs even if the form was already evaluated on the client.
6. If any of the validation controls are found to be invalid through the server-side check, the page is redisplayed with the appropriate error messages included.
7. If the form passes all validation on both the server and client, the page processing sequence continues with the event that triggered the postback firing.
Disabling Client-Side Validation on the Entire Form

An easy way to disable all client-side form validation is to provide the clienttarget=downlevel attribute in the Page directive at the top of your page. The directive looks like this:
<%@ Page Language="VB" codebehind="MyPage1.vb" Inherits
MyApp.MyPage1" clienttarget=downlevel>

You need to be careful when you do this because it not only disables all client-side validation, it also disables any other client-side server control functionality. You can also disable client-side form validation for all validation controls by setting the global page variable Page_PostIfValidationError to True.
The only time you would do either of these is when you have included some validation controls through a common include for the page or embedded them in a custom control. Alternately, you can opt not to include the validation controls on the page.
You can disable all client-side form validation using a number of different methods depending upon the type of control that the user activates. For a regular HTML control, you can set the Page_ValidationActive property to false. For example:
<input type=button runat=server id=cmdCancel value="Cancel"
onClick="Page_ValidationActive=false;"
onServerClick="cmdCancel_Click">
Please note that it is important to set the onServerClick event to equal the event you have defined in the codebehind page for the control; otherwise, the event won't fire since you have overridden the onClick event.
For a server-side control, disabling all form validation requires some client-side code, like this:
<asp:button runat=server id=cmdCancel Text="Cancel"
onClick="cmdCancel_Click">

<script language="JavaScript>
document.all["cmdCancel"].onclick =
new function("Page_ValidationActive=false;");
</script>
The effect of these last two examples is that all client-side validation has been turned off when the Cancel button is pressed. You will still have to bypass server-side validation if the server code uses the Page.IsValid property
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I disable form fields? GDevakii HTML, CSS and Javascript Coding Techniques 7 08-04-2008 07:04 PM
Date/time stamp a form field as the form is submitted itbarota HTML, CSS and Javascript Coding Techniques 1 02-06-2008 10:16 PM
How can I clear the form field values after the user has submitted the form for clien itbarota HTML, CSS and Javascript Coding Techniques 1 11-01-2007 11:39 PM
How can I pass a hidden value to a form and submit that form when a text link is clic itbarota HTML, CSS and Javascript Coding Techniques 1 10-17-2007 08:07 AM
Form Validation using JavaScript S.Vinothkumar HTML, CSS and Javascript Coding Techniques 10 09-06-2007 08:14 AM


All times are GMT -7. The time now is 08:56 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0