Hey I'm new to this forum and I have a problem developing an asp.net custom server control. I already asked a question on stackoverflow but i don't get any answers. So I give it a try here:
Im trying to create a server control, which I can use like this:
<cc1:MyControl runat="server" ID="MyControl1"><cc1:Item MyProperty="Item 1"><cc1:Item MyProperty="Item 1.1"></cc1:Item><cc1:Item MyProperty="Item 1.2"></cc1:Item><cc1:Item><cc1:Item MyProperty="Item 2"><cc1:Item MyProperty="Item 2.1"><cc1:Item MyProperty="Item 2.1.1"></cc1:Item><cc1:Item MyProperty="Item 2.1.2"></cc1:Item></cc1:Item><cc1:Item MyProperty="Item 3"></cc1:Item></cc1:MyControl>
I tried it with the following code:
[ParseChildren(true, DefaultProperty="Item")]
public class MyControl : Control {
public MyControl() {
this.Items = new List<Item>();
}
[PersistenceMode(PersistenceMode.InnerDefaultProperty)]
public List<Item> Items { get; set; }
}
[ParseChildren(true, DefaultProperty="Item")]
public Class Item {
public string MyProperty { get; set; }
[PersistenceMode(PersistenceMode.InnerDefaultProperty)]
public List<Item> Items { get; set; }
}But this does not work.