in the course of the room charge system when. In order to verify that the text box is empty, the user exists, is legal, and so on. We all have to write the code separately. Learning the validation Controls for ASP.
ASP Enables easy validation of user input.
Let's think about The six types of validation controls that are common to ASP.
1 , basic validation controls:
(1) RequiredFieldValidator: Limit empty fields (mandatory field validation) to check for input values
Example: When landing. You need to verify that the input username and password are empty
<asp:requiredfieldvalidator id= "RequiredFieldValidator1" runat= "Server" controltovalidate= "txtUserName" Errormessage= "username must be entered" ></asp:RequiredFieldValidator>
(2) Basic Comparative Control
a , CompareValidator: Compare two fields comparison verification) two inputs per set
Example: When we change password. The first input password and the second input is consistent, can use this control.
<asp:comparevalidator id= "CompareValidator1" runat= "Server" controltocompare= "TxtPassword1" controltovalidate= " TxtPassword2 "errormessage=" two times password inconsistent "></asp:CompareValidator>
b , RangeValidator: checks whether the specified range (range validation) input is in the specified range
For example: the size of the input information range
For example: the size of the input information range
(3) RegularExpressionValidator: use a regular table to check the value (normal form validation) the normal table validation control
(4) CustomValidator: Check values (self-defined validation) by client or server function to define validation controls yourself
3 , validation summary control
(1) ValidationSummary: list validation errors for all controls in the page (validation Summary) Summary validation Results
Example: summary of all validation information
<span style= "font-family:kaiti_gb2312; Background-color:rgb (255, 255, 255); " > </span>
Page.IsValid Properties:
<scrip language= "C #" runat= "Server" >void subbtn (Object src,eventarge E) {if (page.isvalid==true) <span style= " White-space:pre "></span>{lblmessage.text=" page valid ";}} </script>
Page: The current entire page, no matter what one does not pass the value to verify it is false.
To summarize:
Each validation control runs a specific type of validation and presents its own custom SMS prompt when validation fails. Validation control Our development provides a very great help, we do not need too much code, you can verify various certifications.
Asp. NET validation controls