This is an area that could afford some investigation on how ASP.NET delivers different code to different browsers depending on their capabilities. As I've said, ASP.NET is pretty smart about handling browser capabilities and rendering code that different browsers can handle.
By default, ASP.NET lumps browsers together as uplevel and downlevel browsers.
Uplevel. Internet Explorer 4.x and up
Downlevel. Basically everything else, including Netscape 6.x
These aren't hard and fast rules for all Web server controls, but where validators are concerned, the uplevel browsers deliver both JavaScript client-side validation and server-side validation, and downlevel browsers are restricted to server-side validation. Take a look at the code generated for CompareValidator in both an uplevel and downlevel browser.
<html> <head> <title>Validators - Compare</title> </head> <body bgcolor="#FFFFFF" text="#000000"> <form name="_ctl0" method="post" action="web_comparevalidator_vb.aspx" language="javascript" onsubmit="ValidatorOnSubmit();" > <input type="hidden" name="__VIEWSTATE" value="dDwtMTI1OTcyOTYwNzs7Pv8j9BzKw7eb4mzYMNwlwPYrQl1R" /> <script language="javascript" src="/books/1/582/1/html/2//aspnet_client/system_web/1_0_3705_0/WebUIValidation. js"></script> <h3>Set Up User Account</h3> Username: <input name="UserName" type="text" /><br> Password: <input name="Password" type="password" /><br> Confirm: <input name="PasswordConfirm" type="password" /><br> <span controltovalidate="PasswordConfirm" errormessage="Hey, They don't Match" evaluationfunction="CompareValidatorEvaluateIsValid" controltocompare="Password" controlhookup="Password" style="color:Red;visibility:hidden;">Hey, They don't Match</ span><br> <input type="submit" name="_ctl1" value="Submit" onclick="if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); " language="javascript" /><br> <script language="javascript"> <! var Page_Validators = new Array(document.all["ComparePasswords"]); // > </script> <script language="javascript"> <! var Page_ValidationActive = false; if (typeof(clientInformation) != "undefined" && clientInformation.appName.indexOf( "Explorer") != -1) { if (typeof(Page_ValidationVer) == "undefined") alert("Unable to find script library '/aspnet_client/system_web/1_0_3705_0/ WebUIValidation.js'. Try placing this file manually, or reinstall by running 'aspnet_regiis -c'."); else if (Page_ValidationVer != "125") alert("This page uses an incorrect version of WebUIValidation.js. The page expects version 125. The script library is " + Page_ValidationVer + "."); else ValidatorOnLoad(); } function ValidatorOnSubmit() { if (Page_ValidationActive) { ValidatorCommonOnSubmit(); } } // > </script> </form> </body> </html>
<html> <head> <title>Validators - Compare</title> </head> <body bgcolor="#FFFFFF" text="#000000"> <form name="_ctl0" method="post" action="web_comparevalidator_vb.aspx" > <input type="hidden" name="__VIEWSTATE" value="dDwtMTI1OTcyOTYwNzs7Pv8j9BzKw7eb4mzYMNwlwPYrQl1R" /> <h3>Set Up User Account</h3> Username: <input name="UserName" type="text" /><br> Password: <input name="Password" type="password" /><br> Confirm: <input name="PasswordConfirm" type="password" /><br> <br> <input type="submit" name="_ctl1" value="Submit" onclick="if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); " language="javascript" /><br> </form> </body> </html>
The downlevel code block doesn't have the weight of the JavaScript, but remember that it must make a round trip to the server to validate the data, whereas the uplevel browser can handle client-side validation.
To investigate more about the function of ASP.NET and browser capabilities, check out the following URL for the .NET Framework SDK. It will supply you with a lot of information on how ASP.NET handles browsers and how you can manipulate what code is delivered to the browser through the HTTPBrowserCapabilites object.
ms-help://MS.NETFrameworkSDK/cpguidenf/html/cpconWebFormsControlsBrowserCapabilities.htm
Top |