I want to do something like (Updated example):
<uc:Tabs> <Tab Name='A handy tab'> <Node Url='~/Default.aspx' /> <Node Url='~/Node2.aspx' /> </Tab> <Tab Name='Another handy tab'> <Node Url='~/Neato.aspx' /> <Node Url='~/Node3.aspx' /> <Node Url='~/Node4.aspx' /> </Tab> <uc:Tabs>
Possible? Any tutorials or how-to’s? I’m not sure what to even search on or what this is called so haven’t found anything so far. Inner controls? Inner collection something something…?
Use the ParseChildrenAttribute and PersistChildrenAttribute attributes:
This will cause any controls you put inside the reference:
To be appended to the end of the Controls collection of your UserControl contents.
However, if you want to have a collection of controls, you should probably use a server control and not a user control. For a control that works like this:
You need a Control class that has a Tabs property; the Tabs property should be a Collection; and it should contain objects of type Tab. I’ve created the three classes here:
And the tab class:
And the tab collection: