Adding validator to simple server control

R

Ron Strong

I have some trivial server controls, derived from various WebControls
(TextBox, DropDownList, etc). The server control wraps the web control and
its label in a number <div>, <span> and <label> elements, with appropriate
class or style to facilitate proper positioning within a form.

I would like to add asp.net validators to these controls inside the server
control -- I cannot add these outside, as the placement of the error message
would be improper.

My question is, can this be done while continuing the current inheritance of
my custom server controls from the asp.net controls such as TextBox, or
must I build a composite control, derived from
System.Web.UI.WebControls.WebControl, that incorporates the asp:TextBox and
the asp:xxxValidator as child controls?

If this can be done without creating a composite control, how can I do it?

Any help would be appreciated.


Ron Strong
 
J

John Saunders

Ron Strong said:
I have some trivial server controls, derived from various WebControls
(TextBox, DropDownList, etc). The server control wraps the web control
and
its label in a number <div>, <span> and <label> elements, with appropriate
class or style to facilitate proper positioning within a form.

I would like to add asp.net validators to these controls inside the server
control -- I cannot add these outside, as the placement of the error
message
would be improper.

My question is, can this be done while continuing the current inheritance
of
my custom server controls from the asp.net controls such as TextBox, or
must I build a composite control, derived from
System.Web.UI.WebControls.WebControl, that incorporates the asp:TextBox
and
the asp:xxxValidator as child controls?

If this can be done without creating a composite control, how can I do it?

You will have to use a Composite Control, but there's no reason that the
control cannot continue to inherit from TextBox or whatever.

John Saunders
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top