Define Validation Control in ASP.NET.
- The validation control is used to implement page level validity of data entered in the server controls.
- This check is done before the page is posted back to the server, thus avoid a round trip to the server.
- If the data does not pass validation, it will display an error message to the user.
- It is an important part of any web application.
There are two types of validation:1. Client side
2. Server side
- Validation controls are mostly used for implementing presentation logic, to validate user input data, data format, data type and data range.
- Client side validation is good, but we have to be dependent on the browser and scripting language support.
- Server validation will work always whether client validation is executed or not.
Following are the six types of validation control:Sr. No. | Validation control | Description |
1. | RequiredFieldValidation Control | It makes an input control a required field. |
2. | CompareValidator Control | It compares the value of one input control to the value of another input control or to a fixed value. |
3. | RangeValidator Control | It checks that the user enters a value that falls between two values. |
4. | RegularExpressionValidator Control | It ensures that the value of an input control matches a specified pattern. |
5. | CustomValidator Control | It allows you to write a method to handle the validation of the value entered. |
6. | ValidationSummary | It displays a report of all validation errors occurred in a web page. |