Custom Client-Side Validation in Web User Control

S

Stuart Whiteford

Guys,

I have a custom validator that has the default property ControlToValidate
plus one called SecondControlToValidate that I have created, like so...

<ows:eitherorvalidator id="eovNumberName" runat="server"
ControlToValidate="txtNumber" SecondControlToValidate="txtName"
EnableClientScript="True"></ows:eitherorvalidator>

....in my Validator Class I have the following...

Protected eitherOrSecondControlToValidate As String

Public Property SecondControlToValidate() As String
Get
Return eitherOrSecondControlToValidate
End Get
Set(ByVal Value As String)
eitherOrSecondControlToValidate = Value
End Set
End Property

Protected Overrides Sub AddAttributesToRender(ByVal writer As
HtmlTextWriter)
If (Me.DetermineRenderUplevel And Me.EnableClientScript) Then
MyBase.AddAttributesToRender(writer)
writer.AddAttribute("secondcontroltovalidate",
Me.SecondControlToValidate)
End If
End Sub

All this works fine when the textboxes and validator is straight on the
page, but I can't get it working in a Web User Control. I know about
UniqueID and ClientID but what I don't know is how get the ClientID from the
string being passed in so I can use it in the AddAttributesToRender Sub (or
should I be passing in a Control instead).

Mucho head scratching.

TIA,
Stuart.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top