BaseCompareValidator Class

Serves as the abstract base class for validation controls that perform typed comparisons.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

Public MustInherit Class BaseCompareValidator
	Inherits BaseValidator
Dim instance As BaseCompareValidator

public abstract class BaseCompareValidator extends BaseValidator
public abstract class BaseCompareValidator extends BaseValidator

The BaseCompareValidator class is inherited by validation controls that compare values, such as the CompareValidator and RangeValidator controls, to provide basic common functionality.

Use the Type property to specify the data type that that the values are converted to before being compared.


If the value of the input control being validated cannot be converted to the specified data type, validation fails. The IsValid property of the validation control is set to false.

The BaseCompareValidator class also contains several static properties and methods that are useful when performing comparison validations. You can determine whether a string can be converted to a specific data type by using the CanConvert method. The maximum year that can be represented by a two-digit year is contained in the CutoffYear property. The GetFullYear method allows you to convert a two-digit year to a four-digit year.

For more information on validation controls, see BaseValidator.


The markup rendered by default for this control might not conform to accessibility standards such as the Web Content Accessibility Guidelines 1.0 (WCAG) priority 1 guidelines. For details about accessibility support for this control, see ASP.NET Controls and Accessibility.

  • AspNetHostingPermission  for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
  • AspNetHostingPermission  for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0