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?
views:
2663answers:
2
A:
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
Dave Ward
2008-10-24 18:09:46
What if inheriting is not an option? This is really bad move from MS. Why didn't they put the property in the interface?
Slavo
2009-06-05 14:09:27
There is the IValidator interface that defines the basic methods of a validator. BaseValidator just helps you play nice with the other validation controls.
smaclell
2009-08-18 14:58:03
+1
A:
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 ...
}
}
tvanfosson
2008-10-24 18:37:38