Link to home
Start Free TrialLog in
Avatar of g-spot
g-spot

asked on

Programmatically adding a custom validator?

How do I programmatically add a custom validator? I thought something like this would do:

            Dim validationControl As CustomValidator
            validationControl = New CustomValidator()
            validationControl.ID = "valAllDOBValidator"
            validationControl.ControlToValidate = "dropDOBDD"
            validationControl.Text = "Error Message"
            validationControl.CssClass = "highlight"
            validationControl.Display = ValidatorDisplay.Dynamic
            validationControl.EnableClientScript = "False"
            validationControl.ServerValidate = New ServerValidateEventHandler(AddressOf ALLDOBSValidator_ServerValidate)
            plhOtherInsured.Controls.Add(validationControl)

However I'm getting the following error:

Error      29      'Public Event ServerValidate(source As Object, args As System.Web.UI.WebControls.ServerValidateEventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.
ASKER CERTIFIED SOLUTION
Avatar of crisco96
crisco96
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of g-spot
g-spot

ASKER

Brilliant. Thanks.