System.Web.UI.WebControls.RangeValidator Class

Checks whether the value of an input control is within a specified range of values.

See Also: RangeValidator Members


[System.Web.UI.ToolboxData("<{0}:RangeValidator runat="server" ErrorMessage="RangeValidator"></{0}:RangeValidator>")]
public class RangeValidator : BaseCompareValidator


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.


A string data type.


A 32-bit signed integer data type.


A double-precision floating point number data type.


A date data type.


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.


Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0,