开发者

Rendering controls within a Template tag in a custom ServerControl?

I'm working on a custom navigation menu,

I've added the following property within my MenuItem class to allow users add t开发者_如何转开发hem controls into it.

public class MenuItem : INamingContainer
{
.
.
.
    [PersistenceMode(PersistenceMode.InnerProperty)]
    public ITemplate Template { get; set; }
}

I can add the tags in asp.net without any troubles but the controls within Template aren't render!!! and I'm not receive any Exceptions or Errors !

<MdsMenu:Menu ID="Menu1" runat="server">
    <MdsMenu:MenuItem Text="MenuItem 01" href="#" />
    <MdsMenu:MenuItem Text="MenuItem 02" href="#">
        <MdsMenu:MenuItem href="#" Text="Template">
            <Template>
                <asp:Button ID="Button1" runat="server" Text="Button" />
            </Template>
        </MdsMenu:MenuItem>
    </MdsMenu:MenuItem>
    <MdsMenu:MenuItem Text="MenuItem 03" href="#" />
    <MdsMenu:MenuItem Text="MenuItem 04" href="#" />
</MdsMenu:Menu>

How can I render them ?


You have to instantiate your template within some container. See below article for how to develop template based controls:

http://msdn.microsoft.com/en-us/library/36574bf6.aspx - see example for quick start http://msdn.microsoft.com/en-us/library/aa478964.aspx - this is more detailed article

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜