共用方式為


SiteMapPath.PathSeparatorTemplate 屬性

定義

取得或設定控制項樣板以供網站巡覽路徑的路徑分隔符號使用。

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) 物件,以便呈現巡覽路徑之路徑分隔符號的自訂內容。

屬性

範例

下列程式碼範例示範如何在 Web 表單中以宣告方式定義 ImagePathSeparatorTemplate

<%@ 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 屬性設定為任何 Web 服務器控制項,而 ASP.NET 基礎結構會執行必要的步驟,將 Web 服務器控制項包裝為 ITemplate 。 不過,Web 服務器控制項不會實 ITemplate 作 介面;因此,當您以程式設計方式使用 ITemplate 屬性時,您必須撰寫 ITemplate 任何範本程式碼的包裝函式。 然後,屬性 PathSeparatorTemplate 會設定為包裝函式的 ITemplate 實例。

適用於

另請參閱