10.2. Implementing Validation by using ASP.NET Controls

ASP.NET 2.0 provides a number of Web controls that can be used to declaratively validate user input on other ASP.NET controls. Simply put, associating a control with a validation control enables you to perform a specific sort of validation operation on the input that's made to the control. The Validation section of the Toolbox task pane lists the ASP.NET 2.0 validation controls. The validation controls are capable of performing both client-side validation (if the browser supports scripting) and server-side validation.

NOTE

For increased security and suppressing malicious validation, the validation controls are designed to always perform server-side validation even if the client-side validation has already been performed.

10.2.1. Understanding ASP.NET validation controls

As discussed earlier, the process of validating user input to ASP.NET controls using validation controls is by associating the validation control with the ASP.NET control. This is usually done by setting the ControlToValidate property of the validation control. ASP.NET 2.0 makes the following validation controls available:

  • CompareValidator: This control is used to either compare the value of a control to a static value or compare the values of two controls on the Web page. You can also specify the operator for the comparison.

  • CustomValidator: Allows you to write a custom piece of code that can be used to validate user input to a control

  • RangeValidator: Can ...

Get Microsoft® Office SharePoint® Designer 2007 Bible now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.