Groups | Blog | Home
all groups > asp.net building controls > august 2006 >

asp.net building controls : Inherited DropDownList and asp:listitems


Arthur Dent
8/15/2006 3:02:30 PM
Hi all,

I have a control which i wrote which inherits the asp:dropdownlist control.
Works great, all happy.
If when using it i try to declaratively add some items, it complains that
they are unknown types. eg...

<mytag:mydropdownlist id="lstInherited" runat="server"
appenddatabounditems="true" >
<asp:listitem id="" value="select an item" >
</mytag:mydropdownlist>

It complains that asp:listitem is an unknown element. How can i direct the
runtime that my dropdownlist
control can contain asp:listitems like its base class? I assume some sort of
attribute on the class, but i am
looking for any direction as to what attribute.
Thanks in advance,
- Arthur Dent.

Gaurav Vaish (www.EduJini.IN)
8/16/2006 12:00:00 AM
Look into the following attribtue:
ParseChildrenAttribute (System.Web.UI)
PersistChildrenAttribute (System.Web.UI)

The child controls, by default, are not accepted.
You may also need to override AddedParsedSubObject method for type-safety of
the controls added.

--
Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.org
http://www.edujini.in | http://webservices.edujini.in
-------------------


[quoted text, click to view]

Arthur Dent
8/16/2006 11:07:43 AM
Thanks for the tips....
I will check out those attribs/methods.
Cheers!


[quoted text, click to view]

AddThis Social Bookmark Button