本文介绍了创建一个ASP.Net模板化服务器控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够做这样的事

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

这个想法是在这里的是,在的ItemTemplate唯一可以接受的项目是TabItem的类型。有迹象表明,使用该许多asp.net的控件,例如ScriptManager类只允许在其各种收藏指定特定类型的对象。也许这就是关键这个..我想补充,而不是一个模板的集合。

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.

我们的想法是,在code,我会再遍历每个TabItem的,创建标签,因为我希望它看起来(可能呈现的div等)。

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有一起来看看最MSDN链接的关于如何创建模板控件,但它似乎没有做什么我希望它。

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.

推荐答案

您需要或者模板控件或可以解析其内容(阅读关于 ParseChildrenAttribute(自定义控件的typeof()))。看看。虽然不完全的情况下,它可以激励你。

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.

这篇关于创建一个ASP.Net模板化服务器控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 20:16