The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

WEB CONTROL - Create required text box but not a drop down list

I have the following code for creating a web control. It basically extends a text box and adds a required field validator and an ajax extension. However, when I change the class that it inherits from to a dropdownlist, I get an error.

You need to inherit from CompositeControl (I think) and then add the textbox and such to that. As the exception notes, TextBoxes cannot have child controls and since you are inheriting from TextBox you are SOL.

Protip: make your composite control implement ITextControl if you want it to behave like a text box.

Thanks for the help. The textbox is fine to add child controls, it's when I make it a drop down list that I get that error. The problem with using the Composite Control is that I have to add properties to mimic what I already have in the textbox. It's not so bad with the textbox, but if I have to do it with a drop down list it will be that much more difficult to add list items.

Wow! I would have thought there would be more discussion on this. That others would have looked into extending the basic input controls.

Basically, I am looking for a text box, drop down list, and radio button list that I can add a few properties to like required. If I go the route of using the composite control, I end up putting a lot development into just trying to get the control to have the same basic functionality of a text box or a drop down list.