asp.net.ph

CompareValidator.ValueToCompare Property

System.Web.UI.WebControls Namespace   CompareValidator Class


Sets or retrieves a constant value to compare with.

Syntax


Inline <asp:comparevalidator valuetocompare = strValue ... >
Script CompareValidator.ValueToCompare = strValue

Property Value


strValue String specifying the constant value to compare with the value entered by the user into the input control being validated.

The property is read/write with no default value.

Remarks

Use the ValueToCompare property to specify a constant value to compare with the value entered by the user into 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 the constant value specified by this property fails to convert to the data type specified by the Type property, an exception is thrown.

Example

The following example shows how to declaratively set the ValueToCompare property of a CompareValidator control at design time.

<asp:comparevalidator id = "compValidator" 
   controltovalidate = "myTextBox"
   valuetocompare = "0" type = "Integer"
   enableclientscript = "False"  
   runat = "server" />

The example below shows how to programmatically set that same ValueToCompare property above at run time.

Random rand_number = new Random ( );
compValidator.ValueToCompare = rand_number.Next ( 1, 10 ).ToString ( );

 Show me 

See Also

CompareValidator Members   Validating Against a Specific Value Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph