Data validation Controls

Source: Internet
Author: User

1, non-null data validation control Requiredfiledvalidator.

Property: Controltovaliata refers to which control the validation control validates. For example, verify the ID property of the TextBox control Txtpwd, as long as the requiredfiledvalidator. The Controltovalidata property of the control is set to Txtpwd. Code: this. Requiredfiledvalidator1.controltovalidata= "Txtpwd";

ErrorMessage property: Used to specify the error message text that is displayed when the Requiredfiledvalidator control is used in a page. Code: this. Requeiredfiledvalidator1.errormessage= "*";

2. Data Comparison validation controls

CompareValidator:

Important attribute: ControlToCompare Specifies the ID of the control for which you want to compare values. For example, verify the ID two times.

This.comparevalidator1.controltocompare= "Txtpwd";

This.comparevalidator1.controltovalidate= "" Txtrepwd:

Operator property: The action that is performed when the validation occurs. For example, verify that you entered the password and re-enter the password consistently.

this.comparevalidator1.operator=validationcompareoperator.equal;

Type property: Specifies the data type of the two values to be compared, such as verifying the data type of the two

This ... type=validationdatatype.string;

ValueToCompare Property: Specifies the value to compare.

  <title>Data validation Technology</title></Head><Body>    <formID= "Form1"runat= "Server">    <Div>    <H2>Data validation Technology</H2>        <H3>Non-null data validation</H3>        <Div>            <Asp:labelID= "Lab"Text= "User Information"runat= "Server" ></Asp:label><BR/><BR/>            <Asp:labelID= "Name"Text= "Name:"runat= "Server" ></Asp:label>            <Asp:textboxID= "Txtname"runat= "Server" ></Asp:textbox>                        <Asp:requiredfieldvalidatorID= "Redfile"runat= "Server"ControlToValidate= "Txtname"SetFocusOnError= "true"errormessage= "Name cannot be empty" ></Asp:requiredfieldvalidator><BR/><BR/><BR/>            <Asp:buttonID= "Btok"runat= "Server"Text= "Verify"OnClick= "Btok_click"style= "height:21px"  />        </Div>    </Div>        <Div>            <HR/>            <H3>Data comparison control validation</H3>            <var>                <Asp:labelID= "Labtxt"runat= "Server"Text= "User Information"BorderStyle= "NotSet"></Asp:label><BR/>                </var>                <Asp:labelID= "LAB2"runat= "Server"Text= "Name:"></Asp:label>                <Asp:textboxID= "Lab3"runat= "Server" ></Asp:textbox>                                <Asp:requiredfieldvalidatorID= "RequFlie2"runat= "Server"errormessage= "Name cannot be empty"SetFocusOnError= "true"ControlToValidate= "Txtname"></Asp:requiredfieldvalidator><BR/><BR/>                <Asp:labelID= "LAB4"runat= "Server"Text= "Password:" ></Asp:label>                <Asp:textboxID= "Txtpwd"runat= "Server"TextMode= "Password" ></Asp:textbox><BR/><BR/>                <Asp:labelID= "Lab5"runat= "Server"Text= "Confirm Password:"></Asp:label>                <Asp:textboxID= "Txtrepwd"runat= "Server"TextMode= "Password" ></Asp:textbox>            <Asp:comparevalidatorID= "Comval"runat= "Server"ControlToValidate= "Txtrepwd"ControlToCompare= "Txtpwd"errormessage= "The confirmation password does not match the original password"></Asp:comparevalidator><BR/><BR/>            <Asp:buttonID= "Btncheck"runat= "Server"Text= "Verify 2"OnClick= "btnCheck_Click"  />                                                  </Div>    </form>

Data validation Controls

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.