Export (0) Print
Expand All

SiteMapPath.NodeTemplate Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets a control template to use for all functional nodes of a site navigation path.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

[TemplateContainerAttribute(typeof(SiteMapNodeItem))] 
public virtual ITemplate NodeTemplate { get; set; }
/** @property */
public ITemplate get_NodeTemplate ()

/** @property */
public void set_NodeTemplate (ITemplate value)

public function get NodeTemplate () : ITemplate

public function set NodeTemplate (value : ITemplate)

Property Value

An ITemplate object that implements the InstantiateIn method, to render custom content for each node of a navigation path.

Set the NodeTemplate to an ITemplate object to use an Image or some other control, such as a Label, as a user interface element for all navigation path nodes.

If the NodeTemplate property is set, the template overrides both the navigation node text displayed and any NodeStyle applied to it. For the current and root nodes, if a CurrentNodeTemplate or RootNodeTemplate is set, these templates override the NodeTemplate.

You can declaratively set the NodeTemplate property to any Web server control, and the ASP.NET infrastructure performs the necessary steps to wrap the Web server control as an ITemplate object. However, Web server controls do not implement the ITemplate interface; therefore, when you work with the ITemplate properties programmatically, you must write an ITemplate wrapper for any template code. Then, the RootNodeTemplate property is set to an instance of the ITemplate wrapper.

The following code example demonstrates how a NodeTemplate, when one is specified, overrides styles defined for all nodes, including special styles for the root node and current node.

<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<SCRIPT runat="server">
</SCRIPT>

<HTML>
    <BODY>
        <FORM ID="Form1" runat="server">

            <!-- The following example demonstrates some of the orders
                 of precedence when applying styles and templates to
                 functional nodes of a SiteMapPath.

                 A NodeStyle, RootNodeStyle, and CurrentNodeStyle are
                 all defined. However, so is a NodeTemplate. The template
                 is applied to all nodes, and the styles ignored. -->

            <asp:SiteMapPath ID="SiteMapPath1" runat="server"
                RenderCurrentNodeAsLink="true"
                NodeStyle-Font-Name="Franklin Gothic Medium"
                NodeStyle-Font-Underline="true"
                NodeStyle-Font-Bold="true"
                RootNodeStyle-Font-Name="Symbol"
                RootNodeStyle-Font-Bold="false"
                CurrentNodeStyle-Font-Name="Verdana"
                CurrentNodeStyle-Font-Size="10pt"
                CurrentNodeStyle-Font-Bold="true"
                CurrentNodeStyle-ForeColor="red"
                CurrentNodeStyle-Font-Underline="false"
                HoverNodeStyle-ForeColor="blue"
                HoverNodeStyle-Font-Underline="true">
                <NODETEMPLATE>
                        <asp:CheckBox id="CheckBox1" runat="server" Checked=true />
                        <asp:TextBox id="TextBox1" runat="server" Text="Declarative template" />
                </NODETEMPLATE>
            </asp:SiteMapPath>


        </FORM>
    </BODY>
</HTML>

<%@ Page Language="VJ#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<SCRIPT runat="server">
</SCRIPT>

<HTML>
    <BODY>
        <FORM ID="Form1" runat="server">

            <!-- The following example demonstrates some of the orders
                 of precedence when applying styles and templates to
                 functional nodes of a SiteMapPath.

                 A NodeStyle, RootNodeStyle, and CurrentNodeStyle are
                 all defined. However, so is a NodeTemplate. The template
                 is applied to all nodes, and the styles ignored. -->

            <asp:SiteMapPath ID="SiteMapPath1" runat="server"
                RenderCurrentNodeAsLink="true"
                NodeStyle-Font-Name="Franklin Gothic Medium"
                NodeStyle-Font-Underline="true"
                NodeStyle-Font-Bold="true"
                RootNodeStyle-Font-Name="Symbol"
                RootNodeStyle-Font-Bold="false"
                CurrentNodeStyle-Font-Name="Verdana"
                CurrentNodeStyle-Font-Size="10pt"
                CurrentNodeStyle-Font-Bold="true"
                CurrentNodeStyle-ForeColor="red"
                CurrentNodeStyle-Font-Underline="false"
                HoverNodeStyle-ForeColor="blue"
                HoverNodeStyle-Font-Underline="true">
                <NODETEMPLATE>
                        <asp:CheckBox id="CheckBox1" runat="server" Checked=true />
                        <asp:TextBox id="TextBox1" runat="server" Text="Declarative template" />
                </NODETEMPLATE>
            </asp:SiteMapPath>


        </FORM>
    </BODY>
</HTML>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2015 Microsoft