OK, let me be more specific. I know how to create a control with a collection property, but what I’ve never done is written one that has markup associated with it.
What I want to know is, given an control defined like this …
public class MyControl
{
public List<MySubItems> Items {get; set;}
}
What do I have to do to be able to create markup, like this…
<MyStuff:MyControl runat="server" ID="MyControl1">
<Items>
<MySubItem ... />
<MySubItem ... />
</Items>
</MyStuff:MyControl>
Apologies if this seems a bit of a noddy question, but I’ve never done this before.
—
Stuart
You’ll need to apply the DesignerSerializationVisibilityAttribute along with PersistenceModeAttribute on your property. Assuming it’s a ASP.NET control.
This is what it would look like –
See MSDN: Web Control Collection Property Example for a detailed example.