I would like to know how to add some additional child nodes to a custom user control class derived from System.Web.UI.Control.
For example currently I have a cont
You want to be able to describe asp.net control properties declaratively.
To be able to have the following markup:
You need the following code:
[ParseChildren(true)]
[PersistChildren(true)]
[ToolboxData("<{0}:CustomControlUno runat=server>{0}:CustomControlUno>")]
public class CustomControlUno : WebControl, INamingContainer
{
private Control1ChildrenCollection _children;
[PersistenceMode(PersistenceMode.InnerProperty)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public Control1ChildrenCollection Children
{
get
{
if (_children == null)
_children = new Control1ChildrenCollection();
return _children;
}
}
}
public class Control1ChildrenCollection : List
{
}
public class Control1Child
{
public int IntegerProperty { get; set; }
private string StringProperty { get; set; }
}