Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

asp.net custom server control with collections containing themselves

$
0
0

 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.

 


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>