SiteMapNodeItemType 列舉
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
SiteMapNodeItemType 控制項使用 SiteMapPath 列舉來識別節點階層架構中的 SiteMapNodeItem 節點的類型。
public enum class SiteMapNodeItemType
public enum SiteMapNodeItemType
type SiteMapNodeItemType =
Public Enum SiteMapNodeItemType
- 繼承
欄位
Current | 2 | 網站巡覽路徑中目前檢視的網頁。 |
Parent | 1 | 網站巡覽路徑中目前所檢視網頁的父節點。 凡是巡覽階層架構中介於根節點與目前節點之間的任何節點,都是其父節點。 |
PathSeparator | 3 | 網站導覽巡覽路徑分隔字元。 SiteMapPath 控制項的預設分隔符號是 ">" 字元。 |
Root | 0 | 網站巡覽階層架構的最高節點。 只能有一個根節點。 |
範例
下列範例示範如何在 方法內SiteMapPath.InitializeItem建立 SiteMapNodeItem 之後呼叫 SiteMapPath.OnItemCreated 方法。 這個範例是提供給 類別之較大範例的 SiteMapPath 一部分。
private void AddDropDownListAfterCurrentNode(SiteMapNodeItem item) {
SiteMapNodeCollection childNodes = item.SiteMapNode.ChildNodes;
// Only do this work if there are child nodes.
if (childNodes != null) {
// Add another PathSeparator after the CurrentNode.
SiteMapNodeItem finalSeparator =
new SiteMapNodeItem(item.ItemIndex,
SiteMapNodeItemType.PathSeparator);
SiteMapNodeItemEventArgs eventArgs =
new SiteMapNodeItemEventArgs(finalSeparator);
InitializeItem(finalSeparator);
// Call OnItemCreated every time a SiteMapNodeItem is
// created and initialized.
OnItemCreated(eventArgs);
// The pathSeparator does not bind to any SiteMapNode, so
// do not call DataBind on the SiteMapNodeItem.
item.Controls.Add(finalSeparator);
// Create a DropDownList and populate it with the children of the
// CurrentNode. There are no styles or templates that are applied
// to the DropDownList control. If OnSelectedIndexChanged is raised,
// the event handler redirects to the page selected.
// The CurrentNode has child nodes.
DropDownList ddList = new DropDownList();
ddList.AutoPostBack = true;
ddList.SelectedIndexChanged += new EventHandler(this.DropDownNavPathEventHandler);
// Add a ListItem to the DropDownList for every node in the
// SiteMapNodes collection.
foreach (SiteMapNode node in childNodes) {
ddList.Items.Add(new ListItem(node.Title, node.Url));
}
item.Controls.Add(ddList);
}
}
Private Sub AddDropDownListAfterCurrentNode(item As SiteMapNodeItem)
Dim childNodes As SiteMapNodeCollection = item.SiteMapNode.ChildNodes
' Only do this work if there are child nodes.
If Not (childNodes Is Nothing) Then
' Add another PathSeparator after the CurrentNode.
Dim finalSeparator As New SiteMapNodeItem(item.ItemIndex, SiteMapNodeItemType.PathSeparator)
Dim eventArgs As New SiteMapNodeItemEventArgs(finalSeparator)
InitializeItem(finalSeparator)
' Call OnItemCreated every time a SiteMapNodeItem is
' created and initialized.
OnItemCreated(eventArgs)
' The pathSeparator does not bind to any SiteMapNode, so
' do not call DataBind on the SiteMapNodeItem.
item.Controls.Add(finalSeparator)
' Create a DropDownList and populate it with the children of the
' CurrentNode. There are no styles or templates that are applied
' to the DropDownList control. If OnSelectedIndexChanged is raised,
' the event handler redirects to the page selected.
' The CurrentNode has child nodes.
Dim ddList As New DropDownList()
ddList.AutoPostBack = True
AddHandler ddList.SelectedIndexChanged, AddressOf Me.DropDownNavPathEventHandler
' Add a ListItem to the DropDownList for every node in the
' SiteMapNodes collection.
Dim node As SiteMapNode
For Each node In childNodes
ddList.Items.Add(New ListItem(node.Title, node.Url))
Next node
item.Controls.Add(ddList)
End If
End Sub
備註
控件 SiteMapPath 會將其網站導覽信息當做 物件的集合 SiteMapNodeItem 來管理。 SiteMapNodeItem 物件代表功能上不同類型的 SiteMapNode 節點。 因此,它們是由 SiteMapPath 控件所管理。 下列清單描述可用的節點類型:
一個節點,代表目前檢視的頁面。
一個節點,也就是網站導覽階層的最上層節點。
頂端節點與目前節點之間的零個或多個節點 (父節點) 。
代表網站導覽路徑分隔符的零個或多個節點。
每個節點都會將數據系結至基礎 SiteMapNode,但PathSeparator類型的節點除外。