If the classic Entry Program for desktop development outputs "Hello Word" on the console, the web entry program is usually a simple registration page (of course, login data may be written to death without involving the database, for example, in the Code or in the configuration file ). The login form has many issues, except to verify that the user name and password match, whether the "user name" is blank, the email format, and the age range must be considered. You may be able to use statements in the background code, but it is worth the candle, because Microsoft's user-friendly operations have provided you with controls in this area, called verification controls. The following is a summary of the properties of the verification control.
1,RequiredFieldValidator(Verify the invalid value control)
The control is translated into a non-empty control in English. It has an important attribute: ControlToValidate, which is used to set whether the property value of the verified control is null (for TextBox, the property value is "Text"), so you only need to select the control to bind in ControlValidate (for example, the ID of the TextBox of the "Login Name.
If gender verification is a drop-down box (not selected by default), this control can also be verified using RequiredFieldValidate (the drop-down box has two attributes: "TextField" and "ValueField ", the former is used to display the value on the page. After a value is selected, the real value can be obtained through ValueField ). If you use RequiredFieldValidate to verify the drop-down box, it verifies its ValueField value. In this case, you must set another InitialValue. This attribute indicates that if the value of the verified control is equal to the value in InitialValue, it will be regarded as an invalid value.
Conclusion 1: in fact, the criterion for determining the invalid value of RequiredFieldValidate is to compare whether the value of the compared control is consistent with that of InitialValue. If the same value is determined to be illegal, therefore, it is not always "null". I think the name of this control is called "illegal Verification" as well.
In addition, RequiredFieldValidate has several important attributes (if the following controls have these attributes, they are used in the same way ):
Conclusion 2:
L ErrorMessage: error message (used to display information displayed when verification fails. If Text is set, this attribute will be replaced by Text ).
L Text: message displayed when verification fails (this value is displayed when verification fails; if this value is blank, the ErrorMessage value is displayed ).
L Display: Display Mode (None-error message is not displayed on the control, Static-error message is displayed on the control, hidden after verification, but placeholder, dynamic-displays error information at the control, which is hidden after verification and does not occupy space. It is generally used when a control requires several verification bindings ).
2,CompareValidator(Comparison verification control)
This control is used to compare whether two values are equal.
Conclusion 3:
L ControlToCompare: the ID of the control to be compared.
L ControlToValidate: ID of the control to be compared.
L ValueToCompare: the value to be compared.
L Operator: The comparison symbol. When this condition is not met, an exception event is triggered (Equal-Equal, GreatThan-greater than, greatgatethan-greater than or Equal to, LessThan-less than, and LessEqualThan-less than or Equal ).
[Note: this control cannot verify null values. Therefore, it is generally used with RequiredFieldValidator. You can select either ValueToCompare or ControlToCompare]
3,RegularExpressionValidator(Format verification)
This control verifies whether the bound ID matches the regular expression.
Conclusion 4:
L ValidationExpression: The validation rule (regular expression ).
L ControlToCompare: the ID of the control to be compared.
[Note: this control cannot verify null values, so it is generally used with RequiredFieldValidator]
4,RangeValidator(Range verification)
This control specifically verifies that the bound ID value is within a certain range
Conclusion 5:
L ControlToCompare: the ID of the control to be compared.
L MaximunValue: maximum value.
L MinimunValue: minimum value.
[Note: this control cannot verify null values, so it is generally used with RequiredFieldValidator]
5,CustomValidator(Custom verification)
This control is used to enable custom verification to trigger rule implementation verification (for example, to verify whether a verification code matches the input, Microsoft does not provide such a control, assuming that the verification code is dynamically generated, and put it in the Session, the Session name Code ).
Conclusion 6:
L ControlToCompare: the ID of the control to be compared.
In this case, you should inspire the following events and write code verification (example ):
Code
Protected void CustomValidator1_ServerValidate (object source, ServerValidateEventArgs args)
{
String code = Session ["Code"]. ToString ();
Args. IsValid = (args. Value = code );
}
L args. Isvalid: Verify if it is legal (required ).
L args. Value: the Value of the bound control (which must be compared with another Value ).
[Note: this control must set ValidateEmptyText to True to verify the null value]