Compartilhar via


Validation Server Control Syntax 

Validation server controls enable you to check user input in ASP.NET server controls such as a TextBox and to display a custom message if validation fails. Each validation control performs a specific type of validation. For example, you can check for a specific value or a range of values by using the CompareValidator and RangeValidator controls, respectively. You can also define your own validation criteria using the CustomValidator control. You can specify the location of an error message on the Web page by placing a validation control where you want the message to appear. You can also display a summary of the results from all validation controls on the page by using the ValidationSummary control.

By default, validation is performed when a button control such as Button, ImageButton, or LinkButton is clicked. You can prevent validation from being performed when a button control is clicked by setting the button control's CausesValidation property to false. This property is normally set to false for a cancel or clear button to prevent validation from being performed when the button is clicked.

The following topics cover the ASP.NET syntax for validation controls. These topics include information about all properties that are shared among all validation controls, as well as specific properties for each control that you can declare as an attribute within a specified control's opening tag.

In This Section