SiteMapNodeItemType 列舉

定義

SiteMapNodeItemType 控制項使用 SiteMapPath 列舉來識別節點階層架構中的 SiteMapNodeItem 節點的類型。The SiteMapNodeItemType enumeration is used by the SiteMapPath control to identify the type of a SiteMapNodeItem node within a node hierarchy.

public enum class SiteMapNodeItemType
public enum SiteMapNodeItemType
type SiteMapNodeItemType = 
Public Enum SiteMapNodeItemType
繼承
SiteMapNodeItemType

欄位

Current 2

網站巡覽路徑中目前檢視的網頁。The currently viewed page in the site navigation path.

Parent 1

網站巡覽路徑中目前所檢視網頁的父節點。A parent node of the currently viewed page in the site navigation path. 凡是巡覽階層架構中介於根節點與目前節點之間的任何節點,都是其父節點。A parent node is any node that is found between the root node and the current node in the navigation hierarchy.

PathSeparator 3

網站導覽巡覽路徑分隔字元。A site map navigation path separator. SiteMapPath 控制項的預設分隔符號是 ">" 字元。The default separator for the SiteMapPath control is the ">" character.

Root 0

網站巡覽階層架構的最高節點。The top node of the site navigation hierarchy. 只能有一個根節點。There can be only one root node.

範例

下列範例示範如何在 SiteMapPath.OnItemCreated 方法中建立之後,呼叫方法 SiteMapNodeItem SiteMapPath.InitializeItemThe following example demonstrates how to call the SiteMapPath.OnItemCreated method after creating a SiteMapNodeItem within the SiteMapPath.InitializeItem method. 這個範例是針對類別提供之較大範例的一部分 SiteMapPathThis example is part of a larger example provided for the SiteMapPath class.

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控制項會將其網站導覽資訊當做物件的集合來管理 SiteMapNodeItemThe SiteMapPath control manages its site navigation information as a collection of SiteMapNodeItem objects. SiteMapNodeItem物件代表功能不同類型的 SiteMapNode 節點。SiteMapNodeItem objects represent functionally different types of SiteMapNode nodes. 因此,它們是由控制項所管理 SiteMapPathAccordingly, they are managed by the SiteMapPath control. 下列清單描述可用的節點類型:The following list describes the types of nodes available:

  • 一個節點,代表目前所看到的頁面。One node that represent the currently viewed page.

  • 一個節點,也就是網站導覽階層的最上層節點。One node that is the top node of the site navigation hierarchy.

  • 最上層節點和目前節點(父節點)之間的零個或多個節點。Zero or more nodes between the top node and the current node (parent nodes).

  • 零個或多個代表網站導覽路徑分隔符號的節點。Zero or more nodes that represent site navigation path separators.

SiteMapNode除了 PathSeparator 類型的節點,每個節點都會資料系結至基礎。Each node is data-bound to an underlying SiteMapNode, except nodes of the PathSeparator type.

適用於

另請參閱