WhoIsKB - Kevin Blakeley

Public WebLog WhoIsKb() { return "Random experiences with .Net" ; }

<September 2008>
SuMoTuWeThFrSa
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011


Navigation

Tools I Love

Subscriptions

Post Categories



Dropdownlist does not allow child controls

I got an interesting error today, but first some background.  I am creating a server control that inherits from DropDownList and internally I also add an image server control next to it.  I add this image dynamically by trying to add it to the controls collection of the dropdownlist.  When I try to do this I get an error saying that you cannot add controls to the dropdownlist controls collection.

When I look at the dropdownlist in reflector I noticed that the  CreateControlsCollection has been overridden and an emptycontrolcollection is created.  What this emptycontrolcollection does is enforce the rule that you cannot add controls to the control collection.

Now, I was able to override the CreateControlsCollection for my control, but I am curious as to why they did this.  Does anyone know why?  Its strange because I did this same functionality with a textbox and had no problems.

posted on Thursday, May 20, 2004 1:48 AM by whoiskb





Powered by Dot Net Junkies, by Telligent Systems