Page 2
[
DefaultProperty("Text"),
ToolboxData("<{0}:DualValidator runat=server></{0}:DualValidator>")
] |
Defining Validator
The base class used for this control is the BaseValidator class. By inheriting from the BaseValidator class, you will have access to all of its properties and methods.
Some of the methods that you will have to override in this example are EvaluateIsValid
and the ControlPropertiesValid method. The EvaluateIsValid is used to determine if the value being evaluated is valid or not. The ControlPropertiesValid method is used to determine whether the control defined in the ControlToValidate property is validatable.
public class DualValidator : BaseValidator
{ string strFunctionName ; public DualValidator() :base()
{ //
// TODO: Add constructor logic here
// }
|
TypeConverter
Shows the value of a property as text to the property browser. Also converts the text value to an object.
ValidatedControlConverter
Converts the control to a string and shows the value to the designer as a control that can be validated by a validation control.
You can see in the dropdownlist below, a list of controls that can be validated by the validation control.

FIGURE 1
CategoryAttribute
This attribute defines where in the visual designer your property or event will appear. You can see in Figure 1 above that the PrimaryControl, FirstControlToValidate and the SecondControlToValidate are defined under the BEHAVIOR category group. |
CREATING NEW CONTROL PROPERTIES
I have defined three new properties whose values can be set visually in the properties window of the designer. These three custom properties,the PrimaryControl, FirstControlToValidate and SecondControlToValidate will allow me to define the controls that I desire to validate within the web page.