Client-Side Evaluation

When you run this application, you will find that the error messages will not show as you move from field to field unless you either submit the page, or you set a value and then set it back to the original (e.g., you pick a book and then set the drop-down list back to the initial prompt). In either case, if you are using IE 4 or better, the form is not submitted. You can see this by opening the generated source code for the page, shown in Example 9-2.

Example 9-2. Validation page generated source code

<script src="/Validators/WebResource.axd?a=s&amp;r=WebUIValidation. js&amp;t=632413796581225376" type="text/javascript"></script> <script type="text/javascript"> <!-- function WebForm_OnSubmit() { if (ValidatorOnSubmit() = = false) return false; return true; } // --> </script> <script type="text/javascript"> <!-- var Page_Validators = new Array(document.all["reqFieldBooks"], document. all["reqFieldEdition"], document.all["reqFieldBug"]); // --> </script> <script type="text/javascript"> <!-- var reqFieldBooks = document.all["reqFieldBooks"]; reqFieldBooks.controltovalidate = "ddlBooks"; reqFieldBooks.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid"; reqFieldBooks.initialvalue = "-- Please Pick A Book --"; var reqFieldEdition = document.all["reqFieldEdition"]; reqFieldEdition.controltovalidate = "rblEdition"; reqFieldEdition.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid"; reqFieldEdition.initialvalue = ""; var reqFieldBug = document.all["reqFieldBug"]; ...

Get Programming Visual Basic 2005 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.