S
Steven Nagy
Hi all,
I have a custom user control in an ASP.NET app (.NET 2.0).
This control needs a public property called "ControlToValidate" which
accepts strings.
I need to be able to declare it much as you would with a validator
control, like this:
What is important is that my custom control is able to get the
ClientID of the control passed in.
The above code would only pass "myTextbox" as a string, not the actual
textbox control.
I am curious how to do this. If I were to user a
RequiredFieldValidator, I could set ControlToValidate as per my above
usage. So its this behaviour I want to replicate.
I used reflector to view the RequiredFieldValidator's implementation
of ControlToValidate and it simply inherits from BaseValidator. I
tried using this inheritance also, but kept getting compile errors
because BaseValidator ultimately inherits from Control, not
UserControl (sif that should matter).
Googling brought me no love. I suspect there is an attribute I need to
use, possibly a TypeConverter somewhere, just not sure how.
Any help would be greatly appreciated.
Cheers,
Steven
I have a custom user control in an ASP.NET app (.NET 2.0).
This control needs a public property called "ControlToValidate" which
accepts strings.
I need to be able to declare it much as you would with a validator
control, like this:
What is important is that my custom control is able to get the
ClientID of the control passed in.
The above code would only pass "myTextbox" as a string, not the actual
textbox control.
I am curious how to do this. If I were to user a
RequiredFieldValidator, I could set ControlToValidate as per my above
usage. So its this behaviour I want to replicate.
I used reflector to view the RequiredFieldValidator's implementation
of ControlToValidate and it simply inherits from BaseValidator. I
tried using this inheritance also, but kept getting compile errors
because BaseValidator ultimately inherits from Control, not
UserControl (sif that should matter).
Googling brought me no love. I suspect there is an attribute I need to
use, possibly a TypeConverter somewhere, just not sure how.
Any help would be greatly appreciated.
Cheers,
Steven