BaseCompareValidator::Type Property
Gets or sets the data type that the values being compared are converted to before the comparison is made.
Assembly: System.Web (in System.Web.dll)
public: [ThemeableAttribute(false)] property ValidationDataType Type { ValidationDataType get(); void set(ValidationDataType value); }
Property Value
Type: System.Web.UI.WebControls::ValidationDataTypeOne of the ValidationDataType enumeration values. The default value is String.
| Exception | Condition |
|---|---|
| ArgumentOutOfRangeException | The specified data type is not one of the ValidationDataType values. |
Use the Type property to specify the data type used for comparison. The Type property is used differently by the various comparison validation controls.
Important |
|---|
When the Type property is set to Date and the current calendar type is non-Gregorian, the validator performs server-side validation only. The validator client script supports only Gregorian calendars. |
For example, in the RangeValidator control, all values being compared (the upper bound, lower bound, and value of the input control) are converted to the specified data type before any comparison is performed. However, if you use a CompareValidator control and set its Operator property to ValidationCompareOperator.DataTypeCheck, only the value of the input control is converted to the specified data type.
Note |
|---|
If the value of the input control associated with the validation control cannot be converted to the specified data type, validation fails. The IsValid property of the validation control is set to false. |
The following table lists the values that you can use for the Type property.
Data type | Description |
|---|---|
String | Specifies a string data type. |
Integer | Specifies a 32-bit signed integer data type. |
Double | Specifies a double-precision floating-point number data type. |
Date | Specifies a date data type. |
Currency | Specifies a monetary data type. |
This property cannot be set by themes or style sheet themes. For more information, see ThemeableAttribute and ASP.NET Themes and Skins.
Available since 1.1

