CustomValidator

  • Thread starter Thread starter Jim Heavey
  • Start date Start date
J

Jim Heavey

I have the following code to create a CustomValidator control in code:

'* Add Custom Validator
Dim cvl1 As New CustomValidator()
cvl1.ID = "cvlAddRating"
cvl1.Display = ValidatorDisplay.Dynamic
cvl1.ControlToValidate = "ddladdRating"
cvl1.ErrorMessage = "Must make a selection"
cvl1.EnableClientScript = "False"

Now I want to associate this control to the event for the "ServerValidate"
event. How do I do this. I thught maybe the following code was part of
the solution, but not all.

Dim it As New System.Web.UI.WebControls.ServerValidateEventHandler
(AddressOf Me.ValidateDropDownSelection)

Am I headed in the right direction? How do I assign "it" to the control
(cvl1)?
 
Jim said:
Now I want to associate this control to the event for the
"ServerValidate" event. How do I do this.

Just double click the control and start typing.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
Just double click the control and start typing.

As my original note indicated, I am doing all of this in code, so there is
no object from me to double click on!
 
Jim said:
As my original note indicated, I am doing all of this in code, so
there is no object from me to double click on!

So it did. My mistake. Try something like this:

this.CustomValidator1.ServerValidate +=
new ServerValidateEventHandler(CustomValidator1_ServerValidate);

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
Back
Top