SiteMapPath.CurrentNodeTemplate 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定控制項樣板,讓表示目前顯示網頁的網站巡覽路徑節點使用。
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; }
[<System.ComponentModel.Browsable(false)>]
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
[<System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.SiteMapNodeItem))>]
member this.CurrentNodeTemplate : System.Web.UI.ITemplate with get, set
Public Overridable Property CurrentNodeTemplate As ITemplate
屬性值
實作 ITemplate 方法的 InstantiateIn(Control) 物件,以便呈現表示目前顯示網頁之巡覽路徑節點的自訂內容。
- 屬性
範例
下列程式碼範例會以宣告方式定義 , CurrentNodeTemplate 並覆寫定義的 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>
備註
CurrentNodeTemplate將 設定為 ITemplate 物件,以使用 Image 控制項或其他控制項,例如 Label ,做為目前節點的使用者介面專案,而不是字串。
CurrentNodeTemplate如果已設定 屬性,範本會覆寫顯示的目前導覽節點文字,以及套用至該文字的任何 CurrentNodeStyle 文字。 不過,如果目前顯示的頁面對應至根節點, RootNodeTemplate 則會使用 或 RootNodeStyle 。
您可以宣告方式將 CurrentNodeTemplate 屬性設定為任何 Web 服務器控制項,而 ASP.NET 基礎結構會執行必要的步驟,將 Web 服務器控制項包裝為 ITemplate 物件。 不過,Web 服務器控制項不會實 ITemplate 作 介面;因此,當您以程式設計方式使用 ITemplate 屬性時,您必須為任何範本程式碼撰寫 ITemplate 包裝函式。 然後,屬性 CurrentNodeTemplate 會設定為包裝函式的 ITemplate 實例。
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應