Sams Teach Yourself ASP.NET in 21 Days, Second Edition
By Chris Payne
Table of Contents
Day 7.  Validating ASP.NET Pages

Today you learned about validating ASP.NET pages with the Validation server controls. These are powerful controls that make it easy to validate user input.

ASP.NET Validation controls are very similar to Web server controls. They're created on the server and render HTML to the browser. Each Validation control watches over the input from one other server control. They rely on client-side JavaScript code to provide client-side validation, and they can also be validated on the server.

Every Validation control should have two properties, at minimum: ControlToValidate, which specifies the server control that should be watched, and ErrorMessage, which contains the text that should be shown to the user if validation fails. You learned how to use each Validation control in your Web forms in "Using Validation Controls."

Validation controls also provide a lot of options for customization. You can use the ValidationSummary control to provide a summary of the error messages in one place, with various formatting options. This control also allows you to alert the user with a pop-up box using the ShowMessageBox property.

Finally, you learned about creating custom validation routines with the CustomValidator control. This control has a OnServerValidate property that specifies which server method should handle the validation. This method can validate the input any way you want, even by comparing against database values.

You've reached the end of the first week! By now, you should have a solid understanding of how ASP.NET and the Web forms framework operate. You've looked at all of the different server controls available to you, and you can even create a few of your own. Next week, you'll start on data access. You'll examine how to interact with databases, XML files, and other forms of data, adding immense power to your applications!


    Sams Teach Yourself ASP. NET in 21 Days
    Sams Teach Yourself ASP.NET in 21 Days (2nd Edition)
    ISBN: 0672324458
    EAN: 2147483647
    Year: 2003
    Pages: 307
    Authors: Chris Payne © 2008-2017.
    If you may any questions please contact us: