I want to do something like (Updated example):
Follow up
Rex M provided the answer but just wanted to follow up on what I've also found for posterity.
It seems like you can do either:
OR
Then within code:
namespace Controls
{
[ToolboxData("<{0}:Tabs runat=server>{0}:Tabs>"), ParseChildren(true, "TabItems")]
public class Tabs : BaseControl, INamingContainer
{
private TabCollection tabItems;
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[PersistenceMode(PersistenceMode.InnerDefaultProperty)]
public TabCollection TabItems
{
get
{
if (tabItems == null)
{
tabItems = new TabCollection();
}
return tabItems;
}
}
protected override void Render(HtmlTextWriter writer)
{
writer.Write("");
int tabNumber = 1;
foreach (Tab tab in TabItems)
{
string li = string.Format("- {1}
", tabNumber, tab.TabText);
tabNumber++;
writer.Write(li);
}
writer.Write("
");
tabNumber = 1;
foreach (Tab tab in TabItems)
{
string div = string.Format("{1}
", tabNumber, tab.InnerHeading);
tabNumber++;
writer.Write(div);
foreach (Node node in tab.NodeItems)
{
string a = string.Format("{1}", node.Url, "Text holder");
writer.Write(a);
}
writer.Write("");
}
writer.Write("");
}
}
public class TabCollection : List { }
[ParseChildren(true, "NodeItems")]
public class Tab
{
private string tabText = string.Empty;
private string innerHeading = string.Empty;
private string showOn = string.Empty;
public string TabText
{
get { return tabText; }
set { tabText = value; }
}
public string InnerHeading
{
get { return innerHeading; }
set { innerHeading = value; }
}
public string ShowOn
{
get { return showOn; }
set { showOn = value; }
}
private NodeCollection nodeItems;
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[PersistenceMode(PersistenceMode.InnerDefaultProperty)]
public NodeCollection NodeItems
{
get
{
if (nodeItems == null)
{
nodeItems = new NodeCollection();
}
return nodeItems;
}
}
}
public class NodeCollection : List { }
public class Node
{
private string url = string.Empty;
public string Url
{
get { return url; }
set { url = value; }
}
}
}
This will obviously be changing (mine's going to be reading from the web.sitemap among other changes), but this should get anyone with the same needs well under their way.