Types of Validation for ASP.NET Server Controls
This page is specific to:.NET Framework Version:1.12.03.03.54.0
Visual Basic and Visual C# Concepts
Types of Validation for ASP.NET Server Controls

The following table lists the types of validation controls available and how you can use them.

Security Note   By default, the Web Forms page automatically validates that malicious users are not attempting to send script to your application. For more information, see Scripting Exploits.
Type of validationControl to useDescription
Required entryRequiredFieldValidatorEnsures that the user does not skip an entry.
Comparison to a valueCompareValidatorCompares a user's entry against a constant value, or against a property value of another control, using a comparison operator (less than, equal, greater than, and so on).
Range checkingRangeValidatorChecks that a user's entry is between specified lower and upper boundaries. You can check ranges within pairs of numbers, alphabetic characters, and dates.
Pattern matchingRegularExpressionValidatorChecks that the entry matches a pattern defined by a regular expression. This type of validation allows you to check for predictable sequences of characters, such as those in social security numbers, e-mail addresses, telephone numbers, postal codes, and so on.
User-definedCustomValidatorChecks the user's entry using validation logic that you write yourself. This type of validation allows you to check for values derived at run time.

You can attach more than one validation control to an input control. For example, you might specify that a control is required, and that it contain a specific range of values.

A related control, the ValidationSummary control, does not perform validation, but it is often used in conjunction with the controls listed above. The purpose of the ValidationSummary control is to display the error messages from all the validation controls on the page together, in a single location. For more information, see Controlling Validation Error Message Display for ASP.NET Server Controls.

See Also

Web Forms Validation | Introduction to Validating User Input in Web Forms

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View