System.Web.UI.WebControls Namespace CompareValidator Class
Sets or retrieves the input control to compare with.
Inline |
<asp:comparevalidator controltocompare = strID ... > |
Script |
CompareValidator.ControlToCompare = strID |
strID |
String specifying the ID of the control to compare with. |
The property is read/write with no default value.
Use the ControlToCompare property to specify an input control, such as a TextBox, to compare with the input control being validated.
You can either compare the value of an input control to another input control, or to a constant value. However, you can not set both the ControlToCompare and ValueToCompare properties at the same time. If both properties are set, ControlToCompare takes precedence.
If ControlToCompare is specified, but the control is invalid, or is not a control on the page, an exception is thrown and no further processing is done.
The following example shows how to declaratively set the ControlToCompare property of a CompareValidator control at design time.
<asp:comparevalidator id = "comp1"
controltovalidate = "txtComp"
controltocompare = "txtCompTo"
type = "String" runat = "server" />
Show me
CompareValidator Members Validating Against a Specific Value