BaseValidator

BaseValidatordisposable

System.Web.UI.WebControls (system.web.dll)abstract class

This abstract class is the basis for all validation controls. It supplies a Validate( ) method, which does not return a value, but updates the IsValid property. When using validation controls on a Web Forms page, you should check the System.Web.UI.Page.IsValid property. This value will be True only if all validation controls on the page have successfully validated their input. The BaseValidator class also provides various other methods that are not used directly when creating a Web Forms page.

The ControlToValidate property specifies the control that a validator will verify. The ErrorMessage property specifies the message that will be displayed in the validation control if validation fails, although this text can be overridden by changing the validation control's Text property. The ErrorMessage will also appear in a page's ValidationSummary control, if present.

By default, ASP.NET will not render any HTML for a control if it is not visible. This means that space will not be allocated for a validation control unless validation fails. The Display property allows you to allocate space for a validation control by specifying ValidatorDisplay.Static, which may be required if your validation control is in a table. You can also set this property to ValidatorDisplay.None to specify that no validation message will be displayed in the control, although one will still be shown in the ValidationSummary control, if used.

public abstract class BaseValidator : Label, System.Web.UI.IValidator {
// Protected Constructors
   protected BaseValidator( );
// Public Instance Properties
   public string ControlToValidate{set; get; }
   public ValidatorDisplay Display{set; get; }
   public bool EnableClientScript{set; get; }
   public override bool Enabled{set; get; }         // overrides WebControl
   public string ErrorMessage{set; get; }           // implements System.Web.UI.IValidator
   public override Color ForeColor{set; get; }                   // overrides WebControl
   public bool IsValid{set; get; }                  // implements System.Web.UI.IValidator
// Protected Instance Properties
   protected bool PropertiesValid{get; }
   protected bool RenderUplevel{get; }
// Public Static Methods
   public static PropertyDescriptor GetValidationProperty(object component);
// Public Instance Methods
   public void Validate( );                          // implements System.Web.UI.IValidator
// Protected Instance Methods
   protected override void AddAttributesToRender(System.Web.UI.HtmlTextWriter writer);// overrides WebControl
   protected void CheckControlValidationProperty(string name, string propertyName);
   protected virtual bool ControlPropertiesValid( );
   protected virtual bool DetermineRenderUplevel( );
   protected abstract bool EvaluateIsValid( );
   protected string GetControlRenderID(string name);
   protected string GetControlValidationValue(string name);
   protected override void OnInit(EventArgs e);                 // overrides System.Web.UI.Control
   protected override void OnPreRender(EventArgs e);            // overrides System.Web.UI.Control
   protected override void OnUnload(EventArgs e);               // overrides System.Web.UI.Control
   protected void RegisterValidatorCommonScript( );
   protected virtual void RegisterValidatorDeclaration( );
   protected override void Render(System.Web.UI.HtmlTextWriter writer);// overrides WebControl
}

Hierarchy

System.Object System.Web.UI.Control(System.ComponentModel.IComponent, System.IDisposable, System.Web.UI.IParserAccessor, System.Web.UI.IDataBindingsAccessor) WebControl(System.Web.UI.IAttributeAccessor) Label BaseValidator(System.Web.UI.IValidator)

Subclasses

BaseCompareValidator, CustomValidator, RegularExpressionValidator, RequiredFieldValidator

Returned By

System.Web.UI.MobileControls.BaseValidator.CreateWebValidator( )



    Part I: Introduction to ASP.NET
    Part III: Namespace Reference
    Chapter 40. The System.Web.UI.MobileControls Namespace
    Chapter 42. The System.Web.UI.WebControls Namespace