See Also: RangeValidator Members
The System.Web.UI.WebControls.RangeValidator control tests whether the value of an input control is within a specified range.
The System.Web.UI.WebControls.RangeValidator control uses four key properties to perform its validation. The BaseValidator.ControlToValidate property contains the input control to validate. The RangeValidator.MinimumValue and RangeValidator.MaximumValue properties specify the minimum and maximum values of the valid range.
The BaseCompareValidator.Type property is used to specify the data type of the values to compare. The values to compare are converted to this data type before the validation operation is performed.
When the BaseCompareValidator.Type property is set to ValidationDataType.Date and the current calendar type is non-Gregorian, the validator performs server-side validation only. The validator client script supports only Gregorian calendars.
The following table lists the different data types that can be compared.
String |
A string data type. |
Integer |
A 32-bit signed integer data type. |
Double |
A double-precision floating point number data type. |
Date |
A date data type. |
Currency |
A decimal data type that can contain currency symbols. |
Validation succeeds if the input control is empty. Use a System.Web.UI.WebControls.RequiredFieldValidator control to make the input control a mandatory field.
The System.Web.UI.WebControls.RangeValidator control throws an exception if the value specified by the RangeValidator.MaximumValue or RangeValidator.MinimumValue property cannot be converted to the specified BaseCompareValidator.Type.
When you use the System.Web.UI.WebControls.RangeValidator control inside an System.Web.UI.UpdatePanel control, make sure that the validator control and the control it is associated with are in the same panel. For more information about using the System.Web.UI.UpdatePanel control for partial-page updates, see Partial-Page Rendering Overview.
For additional information on validation controls, see System.Web.UI.WebControls.BaseValidator.
For information about how to configure this control so that it generates markup that conforms to accessibility standards, see Accessibility in Visual Studio 2010 and ASP.NET 4 and ASP.NET Controls and Accessibility.