For these commonly used control validation, there are separate validation controls available in asp.net. They can satisfy the general, such as Non-empty, scope, comparison and other verification, for the user login page to add input data validation function and authentication code function.
Validation controls:
The validation controls built into the asp.net are: requiredfieldvalidation, rangevalidation, Regularexpressvalidation, Comparevalidation, CustomValidation and ValidationSummary, etc. six kinds. The user-defined validation control, which is not very commonly used (to customize many components, including functions, etc.), is not discussed in this article.
The simple verification interface is as follows (Design view):
As shown in the selection environment, the right red font is the errormessage information for the validation control. The design environment is arranged as follows:
1) requiredfieldvalidation control, its ControlToValidate property is the name of the corresponding text box. For the ControlToValidate property, each validation control corresponds to one, as the subject of the validation;
2) Rangevalidation control, its ControlToValidate property is the age corresponding text box;
3 Comparevalidation control, its ControlToValidate property is the password confirmation corresponding text box. There is also an attribute that is easily confused with the ControlToValidate property: The ControlToCompare property, which corresponds to a text box for the corresponding password. Distinction: The main point is to distinguish the subject, at this time the subject of validation is the password confirmation corresponding box, when using operator (equal, greater than, less than), is the main body of comparison, and compared to the text box, here is the password corresponding text box.
4) Regularexpressvalidation control, its ControlToValidate property is the mailbox corresponding text box;
5) ValidationSummary control, it does not have controltovalidate attribute;
The corresponding foreground code is:
When the text box's input does not match, the interface appears as:
Report:
For all requiredfieldvalidation controls, when they are only for the name box, their corresponding validation controls are invalidated when the remaining boxes are empty. You can assume that except for the RequiredFieldValidation control, the rest of the controls will work on this control.
3 wonderful topics to be attached:
Asp. NET Control Usage Manual
Asp. NET data-bound controls using totals
Asp. NET controls use totals
The above is the entire content of this article, I hope to use asp.net in the validation of the control to help.