开发者

Creating an ASP.Net Templated Server control

I want to be able to do something like this

<test:TabControl id="" runat="server"....>
    <ItemTemplat开发者_StackOverflow中文版e>
        <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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜