Main Page

  Previous Section Next Section

BaseValidator.NET 1.1, disposable

System.Web.UI.MobileControls (system.web.mobile.dll)abstract class

This abstract class is the basis for all mobile validation controls, and it plays the same role as the System.Web.UI.WebControls.BaseValidator class in a full-blown ASP.NET web form, with some minor limitations and the ability for device-specific support. The BaseValidator class includes a Validate( ) method, which does not return a value, but updates the IsValid property. When using validation controls on a mobile page, you should check the MobilePage.IsValid property. This value will only be True if all validation controls on the page have successfully validated their input.

The ControlToValidate property specifies the control that a validator will verify. The ASP.NET mobile controls that support validation include the TextBox (in which case the TextBox.Text property is validated) and the SelectionList control (in which case the SelectionList.SelectedIndex property is validated). You can create custom controls that can participate in validation using the System.Web.UI.ValidationPropertyAttribute attribute.

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 on the page. By default, ASP.NET will not render any output 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 System.Web.UI.WebControls.ValidatorDisplay.Static, which may be required if your validation control is in a table. You can also set this property to System.Web.UI.WebControls.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 : TextControl, System.Web.UI.IValidator {
// Protected Constructorsprotected BaseValidator( );
// Public Instance Properties
   public string ControlToValidate{set; get; }
   public ValidatorDisplay Display{set; get; }
   public string ErrorMessage{set; get; }           // implements System.Web.UI.IValidator
   public bool IsValid{set; get; }                  // implements System.Web.UI.IValidator
   public override string StyleReference{set; get; }             // overrides MobileControl
   public override int VisibleWeight{get; }         // overrides MobileControl
// Public Instance Methods
   public void Validate( );                          // implements System.Web.UI.IValidator
// Protected Instance Methods
   protected void CheckControlValidationProperty(string name, string propertyName);
   protected virtual bool ControlPropertiesValid( );
   protected virtual BaseValidator CreateWebValidator( );
   protected abstract bool EvaluateIsValid( );
   protected override void OnInit(EventArgs e);                 // overrides MobileControl
   protected override void OnPreRender(EventArgs e);            // overrides MobileControl


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


CompareValidator, CustomValidator, RangeValidator, RegularExpressionValidator, RequiredFieldValidator

Returned By

System.Web.UI.MobileControls.Adapters.HtmlValidatorAdapter.Control, System.Web.UI.MobileControls.Adapters.WmlValidatorAdapter.Control

      Previous Section Next Section