SiteMapPath.CurrentNodeTemplate Property

Definition

取得或設定控制項樣板,讓表示目前顯示網頁的網站巡覽路徑節點使用。Gets or sets a control template to use for the node of a site navigation path that represents the currently displayed page.

public:
 virtual property System::Web::UI::ITemplate ^ CurrentNodeTemplate { System::Web::UI::ITemplate ^ get(); void set(System::Web::UI::ITemplate ^ value); };
[System.ComponentModel.Browsable(false)]
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
[System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.SiteMapNodeItem))]
public virtual System.Web.UI.ITemplate CurrentNodeTemplate { get; set; }
member this.CurrentNodeTemplate : System.Web.UI.ITemplate with get, set
Public Overridable Property CurrentNodeTemplate As ITemplate

Property Value

ITemplate

實作 ITemplate 方法的 InstantiateIn(Control) 物件,以便呈現表示目前顯示網頁之巡覽路徑節點的自訂內容。An ITemplate object that implements the InstantiateIn(Control) method, to render custom content for the navigation path node that represents the currently displayed page.

Attributes

Examples

下列程式碼範例會以宣告方式定義 CurrentNodeTemplate 並覆寫已定義的 CurrentNodeStyleThe following code example declaratively defines a CurrentNodeTemplate and overrides a defined CurrentNodeStyle.

<%@ Page Language="C#" %>
<!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>
<%@ 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>

Remarks

CurrentNodeTemplate 設定為 ITemplate 物件,以使用 Image 控制項或一些其他控制項,例如 Label,做為目前節點的使用者介面專案,而不是字串。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.

如果已設定 [CurrentNodeTemplate] 屬性,此範本會覆寫所顯示的目前導覽節點文字,以及套用的任何 CurrentNodeStyleIf the CurrentNodeTemplate property is set, the template overrides both the current navigation node text displayed and any CurrentNodeStyle applied to it. 不過,如果目前顯示的頁面對應到根節點,則會使用 RootNodeTemplateRootNodeStyleIf the currently displayed page corresponds to the root node, however, the RootNodeTemplate or RootNodeStyle is used.

您可以用宣告方式將 CurrentNodeTemplate 屬性設定為任何 Web 服務器控制項,而 ASP.NET 基礎結構會執行必要的步驟,將 Web 服務器控制項包裝為 ITemplate 物件。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. 不過,Web 服務器控制項不會執行 ITemplate 介面;因此,當您以程式設計方式使用 ITemplate 屬性時,您必須為任何範本程式碼撰寫 ITemplate 的包裝函式。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. 然後,CurrentNodeTemplate 屬性會設定為 ITemplate 包裝函式的實例。Then, the CurrentNodeTemplate property is set to an instance of the ITemplate wrapper.

Applies to

See also