Share via


ControlToCompare Property

Sets or returns the ID of the input control to compare. The default value is an empty string ("").

public string ControlToCompare {
   get,
   set
}

Remarks

Specifies the ID of the control to which a value comparison will be made. You can use the ValueToCompare property as an alternative. If both are specified, the value of the ControlToCompare property takes precedence.

Example

The following example demonstrates how to use the 'ControlToCompare property to verify that the intended password was entered by the user.

<mobile:Form runat=server id="Form1" Alignment=center> 
   <mobile:Label runat="server" id="lblUserPwd" 
      Text="Password (req'd)" />
   <mobile:Textbox  runat="server" id="txtUserPwd"/>
   <mobile:RequiredFieldValidator runat="server" id="rfvUserPwd" 
      ControlToValidate="txtUserPwd" />
   <mobile:RegularExpressionValidator runat="server" id="revUserPwd"
      ControlToValidate="txtUserPwd" />
   <mobile:Label runat="server" id="lblUserPwd2" 
      Text="Re-enter Password (req'd)" />
   <mobile:Textbox  runat="server" id="txtUserPwd2"/>
   <Mobile:CompareValidator runat=server id=valcmprPassword Type=String
      ControlToValidate="txtUserPwd"  Operator=Equal 
      ErrorMessage="Passwords did not match!" 
      ControlToCompare="txtUserPwd2"/>
   <mobile:Command runat="server" id="Command1" text="Submit" />
</mobile:Form>

See Also

Web Forms ControlToCompare Property

Applies to: CompareValidator Class