How to implement BaseValidator and IValidator in custom control - ASP.Net

10,173

Solution 1

Inheriting from BaseValidator will give you all of that.

You might find the source for this control useful as a starting point: http://www.codeplex.com/UsernameAvailability

Solution 2

BaseValidator implements the IValidator interface. Simply have your class derive from BaseValidator and override or implement the necessary methods to support your validation logic:

public class MyValidator : BaseValidator
{
   public override bool EvaluateIsValid()
   {
     ... your code here ...
   }
}
Share:
10,173
410
Author by

410

Updated on June 05, 2022

Comments

  • 410
    410 almost 2 years

    I have a custom control that inherits from WebControl and implements IValidator, but I also want to have a property for ValidationGroup. From research, it appears I need to inherit from BaseValidator to do so. Can anybody provide a successfull example from a ASP.Net custom control that implements both BaseValidator and IValidator?

  • Slavo
    Slavo almost 15 years
    What if inheriting is not an option? This is really bad move from MS. Why didn't they put the property in the interface?