Export (0) Print
Expand All

SiteMapPath.CurrentNodeTemplate Property

Gets or sets a control template to use for the node of a site navigation path that represents the currently displayed page.

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

'Declaration
<BrowsableAttribute(False)> _
<PersistenceModeAttribute(PersistenceMode.InnerProperty)> _
<TemplateContainerAttribute(GetType(SiteMapNodeItem))> _
Public Overridable Property CurrentNodeTemplate As ITemplate
<asp:SiteMapPath>
	<CurrentNodeTemplate>ITemplate</CurrentNodeTemplate>
</asp:SiteMapPath>

Property Value

Type: System.Web.UI.ITemplate
An ITemplate object that implements the InstantiateIn method, to render custom content for the navigation path node that represents the currently displayed page.

Set the CurrentNodeTemplate to an ITemplate object to use an Image control or some other control, such as a Label, as the current node's user interface element instead of a string.

If the CurrentNodeTemplate property is set, the template overrides both the current navigation node text displayed and any CurrentNodeStyle applied to it. If the currently displayed page corresponds to the root node, however, the RootNodeTemplate or RootNodeStyle is used.

You can declaratively set the CurrentNodeTemplate 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 CurrentNodeTemplate property is set to an instance of the ITemplate wrapper.

The following code example declaratively defines a CurrentNodeTemplate and overrides a defined CurrentNodeStyle.


<%@ 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 xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<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.

                 The NodeStyle and RootNodeStyle define the same attributes,
                 but are different and conflict with each other: the
                 RootNodeStyle supersedes NodeStyle, and is the style
                 rendered. Notice, however, that the underline style
                 defined by NodeStyle is still applied.

                 Both a CurrentNodeStyle and a CurrentNodeTemplate are
                 defined. A template supersedes a style for a node
                 type, so CurrentNodeTemplate is displayed and CurrentNodeStyle
                 is ignored. -->

            <asp:SiteMapPath ID="SiteMapPath1" runat="server"
                RenderCurrentNodeAsLink="true"
                NodeStyle-Font-Names="Franklin Gothic Medium"
                NodeStyle-Font-Underline="true"
                NodeStyle-Font-Bold="true"
                RootNodeStyle-Font-Names="Symbol"
                RootNodeStyle-Font-Bold="false"
                CurrentNodeStyle-Font-Names="Verdana"
                CurrentNodeStyle-Font-Size="10pt"
                CurrentNodeStyle-Font-Bold="true"
                CurrentNodeStyle-ForeColor="red"
                CurrentNodeStyle-Font-Underline="false">
                <CURRENTNODETEMPLATE>
                        <asp:Image id="Image1" runat="server" ImageUrl="WebForm2.jpg" AlternateText="WebForm2"/>
                </CURRENTNODETEMPLATE>
            </asp:SiteMapPath>


        </form>
    </body>
</html>


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

Community Additions

ADD
Show:
© 2014 Microsoft