Creating an ASP.NET UserControl with collection-type property
-
How can I create a UserControl with a collection-type property which has a collection editor? I've a CompositeControl with an ArrayList-type property which has CollectionEditor-type designer. You can see this property on Properties window with a "..." button which launches a collection editor. This works fine and all but I want to apply the same to a UserControl and I've couldn't manage to pull it off so far. I've done the same thing what I've done with my CompositeControl but the property either doesn't even show on Properties window of the UserControl or shows as a single value property with no "..." editor button. This is what I've done with CompositeControl:
[
DefaultProperty("Contacts"),
ParseChildren(true, "Contacts"),
ToolboxData(
"<{0}:QuickContacts runat=\"server\"> </{0}:QuickContacts>")
]
public class QuickContacts : CompositeControl
{
private ArrayList contactsList;\[ DesignerSerializationVisibility( DesignerSerializationVisibility.Content), Editor(typeof(ContactCollectionEditor), typeof(UITypeEditor)), PersistenceMode(PersistenceMode.InnerProperty) \] public ArrayList Contacts { get { if (contactsList == null) { contactsList = new ArrayList(); } return contactsList; } }
-
How can I create a UserControl with a collection-type property which has a collection editor? I've a CompositeControl with an ArrayList-type property which has CollectionEditor-type designer. You can see this property on Properties window with a "..." button which launches a collection editor. This works fine and all but I want to apply the same to a UserControl and I've couldn't manage to pull it off so far. I've done the same thing what I've done with my CompositeControl but the property either doesn't even show on Properties window of the UserControl or shows as a single value property with no "..." editor button. This is what I've done with CompositeControl:
[
DefaultProperty("Contacts"),
ParseChildren(true, "Contacts"),
ToolboxData(
"<{0}:QuickContacts runat=\"server\"> </{0}:QuickContacts>")
]
public class QuickContacts : CompositeControl
{
private ArrayList contactsList;\[ DesignerSerializationVisibility( DesignerSerializationVisibility.Content), Editor(typeof(ContactCollectionEditor), typeof(UITypeEditor)), PersistenceMode(PersistenceMode.InnerProperty) \] public ArrayList Contacts { get { if (contactsList == null) { contactsList = new ArrayList(); } return contactsList; } }
Sir, I am not an expert but i think you can use the ViewState object.
Help people,so poeple can help you.