Main Page

  Previous Section Next Section

CustomValidator.NET 1.1, disposable

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

The CustomValidator control allows you to define your own validation routines. A similar task could be performed by writing manual validation code in the click event for a submit button, but using a CustomValidator allows you to create validation code that will run any time the page is validated, and can provide a "vote" used for the MobilePage.IsValid property along with all other validation controls. A CustomValidator can also be easily reused to validate multiple controls.

To provide server-side validation, create an event handler for the ServerValidate event. The string from the input control and the result of the validation is stored in the provided System.Web.UI.WebControls.ServerValidateEventArgs object. In this way, the CompareValidator works exactly the same as the System.Web.UI.WebControls.CustomValidator control, although it doesn't include the ability to define client-side validation logic using a JavaScript function, because few mobile devices would support it.

public class CustomValidator : BaseValidator {
// Public Constructors
   public CustomValidator( );
// Protected Instance Methods
   protected override bool ControlPropertiesValid( );             // overrides BaseValidator
   protected override BaseValidator CreateWebValidator( );        // overrides BaseValidator
   protected override bool EvaluateIsValid( );       // overrides BaseValidator
   protected virtual bool OnServerValidate(string value);
// Events
   public event ServerValidateEventHandler ServerValidate;


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) CustomValidator

      Previous Section Next Section