HELP! DropDownList Items property in composite control -- collection editor support question!

N

Nguyen Ly

Hi,

I have a composite web custom control consisting of a textbox, a button, and
a dropdownlist..
I'm trying to expose the Items property from the dropdownlist and it works
fine if I use code to populate the drop down.

When I try to use the Collection editor to add in ListItems by clicking on
the three "..." button next to the Items property, it sort of adds in the
ListItems but the HTML view on the aspx page doesn't show child listitem
controls the way the the DropDownList control does..
ie it does <custom:MyControl id="MyCustomControl" Items="(Collections)" ...
so when I build .. theres an error saying the Items property is read only.

I want the ability to use the visual design-time collection editor with my
composite control in VS so when I click on the three "..." button next to
the Items property.. it allows me to add in ListItems just like the
DropDownList does, and puts in something like this:

<custom:MyControl id="MyCustomControl">
<asp:ListItem value="1">One</asp:ListItem>
<asp:ListItem value="1">Two</asp:ListItem>
</custom:MyControl>

Does anyone know how I can go about doing this?

Thanks for your time :)
 
T

Teemu Keiski

Hi,

you should apply certain attributes for the property that exposes the
collection.

[
PersistenceMode(PersistenceMode.InnerProperty),

DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true)
}
....property goes here

Also note that the property should be read-only and utilize lazy
instantiation.
 

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,020
Latest member
GenesisGai

Latest Threads

Top