SiteMapPath.PathSeparatorTemplate 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定一個控制範本,用於網站導覽路徑的路徑分隔符。
public:
virtual property System::Web::UI::ITemplate ^ PathSeparatorTemplate { 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 PathSeparatorTemplate { 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.PathSeparatorTemplate : System.Web.UI.ITemplate with get, set
Public Overridable Property PathSeparatorTemplate As ITemplate
屬性值
一個 ITemplate 實 InstantiateIn(Control) 作此方法的物件,用以渲染導航路徑分隔符的自訂內容。
- 屬性
範例
以下程式碼範例示範如何在網頁表單中定義 a Image 為 PathSeparatorTemplate 宣告式。
<%@ Page language="c#"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>About Us</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<asp:SiteMapPath
runat="server"
ID="SiteMapPath1"
RootNodeStyle-Font-Names="Verdana"
RootNodeStyle-Font-Italic="True"
RootNodeStyle-ForeColor="Blue"
CurrentNodeStyle-ForeColor="Red">
<PATHSEPARATORTEMPLATE>
<asp:Image id="Image1" runat="server"
GenerateEmptyAlternateText="true"
ImageUrl="6.jpg"></asp:Image>
</PATHSEPARATORTEMPLATE>
</asp:SiteMapPath>
<h1>About Us</h1>
<p>This company was founded in 1899, as the demand for widgets grew.</p>
</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">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>About Us</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<asp:SiteMapPath
runat="server"
ID="SiteMapPath1"
RootNodeStyle-Font-Names="Verdana"
RootNodeStyle-Font-Italic="True"
RootNodeStyle-ForeColor="Blue"
CurrentNodeStyle-ForeColor="Red">
<PATHSEPARATORTEMPLATE>
<asp:Image id="Image1" runat="server"
GenerateEmptyAlternateText="true"
ImageUrl="6.jpg"></asp:Image>
</PATHSEPARATORTEMPLATE>
</asp:SiteMapPath>
<h1>About Us</h1>
<p>This company was founded in 1899, as the demand for widgets grew.</p>
</form>
</body>
</html>
備註
將 設 PathSeparatorTemplate 為 ITemplate 物件,使用 Image 導航節點間的路徑分隔符,例如 , Label作為路徑分隔符,而非字 PathSeparator 串。
如果設定了該 PathSeparatorTemplate 屬性,範本會 PathSeparator 覆蓋顯示的文字以及套用到它的文字 PathSeparatorStyle 。
你可以宣告性地將屬性設定 PathSeparatorTemplate 為任何網頁伺服器控制項,ASP.NET 基礎架構會執行必要的步驟,將網頁伺服器控制項包裝成 ITemplate。 然而,網頁伺服器控制項並未實作介面; ITemplate 因此,當你以程式方式處理 ITemplate 屬性時,必須為任何範本程式碼撰寫 ITemplate 包裝器。 接著,屬性 PathSeparatorTemplate 被設定為包裝器的實例 ITemplate 。