views:

43

answers:

1

Hi,

I want to be able to do something like this

<test:TabControl id="" runat="server"....>
    <ItemTemplate>
        <tabItem label="tab1" />
        <tabItem label="tab2" />
    </ItemTemplate>
</test>

The idea being here is that the only acceptable items in "ItemTemplates" are the tabitem types. There are many asp.net controls that use this, for example the ScriptManager class only allows you to specify certain types of objects under its various collections. Maybe thats the key to this.. I want to add a collection as opposed to a template.

The idea is that in code I will then iterate over each "tabItem" and create the tab as I want it to look (probably rendering div's etc).

Ive had a look at most of MSDN link on how to create templated controls but it doesnt seem to do exactly what I want it to.

Would be grateful for some assistance.

+1  A: 

You need either a templated control or a custom control that can parse its content (Read about ParseChildrenAttribute(typeof())). Take a look at this article. Although not exactly your case it can inspire you.

UserControl
ParseChildrenAttribute(typeof()) was the key to this.
RemotecUk