更新:2007 年 11 月
顯示一組佔用最小頁面空間的文字或影像超連結,讓使用者方便地巡覽網站。
<asp:SiteMapPath
AccessKey="string"
BackColor="color name|#dddddd"
BorderColor="color name|#dddddd"
BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge|
Inset|Outset"
BorderWidth="size"
CssClass="string"
Enabled="True|False"
EnableTheming="True|False"
EnableViewState="True|False"
Font-Bold="True|False"
Font-Italic="True|False"
Font-Names="string"
Font-Overline="True|False"
Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium|
Large|X-Large|XX-Large"
Font-Strikeout="True|False"
Font-Underline="True|False"
ForeColor="color name|#dddddd"
Height="size"
ID="string"
OnDataBinding="DataBinding event handler"
OnDisposed="Disposed event handler"
OnInit="Init event handler"
OnItemCreated="ItemCreated event handler"
OnItemDataBound="ItemDataBound event handler"
OnLoad="Load event handler"
OnPreRender="PreRender event handler"
OnUnload="Unload event handler"
ParentLevelsDisplayed="integer"
PathDirection="RootToCurrent|CurrentToRoot"
PathSeparator="string"
RenderCurrentNodeAsLink="True|False"
runat="server"
ShowToolTips="True|False"
SiteMapProvider="string"
SkinID="string"
SkipLinkText="string"
Style="string"
TabIndex="integer"
ToolTip="string"
Visible="True|False"
Width="size"
>
<CurrentNodeStyle />
<CurrentNodeTemplate>
<!-- child controls -->
</CurrentNodeTemplate>
<NodeStyle />
<NodeTemplate>
<!-- child controls -->
</NodeTemplate>
<PathSeparatorStyle />
<PathSeparatorTemplate>
<!-- child controls -->
</PathSeparatorTemplate>
<RootNodeStyle />
<RootNodeTemplate>
<!-- child controls -->
</RootNodeTemplate>
</asp:SiteMapPath>
備註
SiteMapPath 控制項是網站巡覽控制項,反映 SiteMap 物件提供的資料。它提供了一種節約空間的方法,可以方便地巡覽站台並做為目前所顯示頁面在網站內之位置的參考點。這個控制項型別一般稱之為麵包屑或眉毛,因為它會顯示超連結網頁名稱的階層路徑,並且可以從目前的位置跳離網頁的階層。
SiteMapPath 對於具有深階層式頁面結構的站台很有用,但此時 TreeView 或 Menu 控制項可能需要頁面上的大量空間。
如需 SiteMapPath 控制項和巡覽控制項的詳細資訊,請參閱巡覽工具箱控制項。
範例
下列程式碼範例示範在 Web Form 網頁中如何以宣告方式使用 SiteMapPath 控制項。這個程式碼範例還示範管理樣板和樣式套用至 SiteMapPath 節點之順序的一些優先順序規則。
這個範例使用具有下列結構的預設網站導覽提供者和 Web.sitemap 檔案。
<siteMap>
<siteMapNode title="WebForm1" description="WebForm1" url="WebForm1.aspx" >
<siteMapNode title="WebForm2" description="WebForm2" url="WebForm2.aspx"/>
</siteMapNode>
</siteMap>
<%@ 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>
<%@ 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="VJ#" %>
<!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 supercedes 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 supercedes 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>