SiteMapNodeItemType 列挙型

定義

SiteMapNodeItemType 列挙体は、ノード階層内の SiteMapPath ノードの型を識別するために、SiteMapNodeItem コントロールによって使用されます。

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

フィールド

名前 説明
Root 0

サイト ナビゲーション階層の最上位ノード。 ルート ノードは 1 つだけ存在できます。

Parent 1

サイト ナビゲーション パスで現在表示されているページの親ノード。 親ノードは、ルート ノードとナビゲーション階層内の現在のノードの間にある任意のノードです。

Current 2

サイト ナビゲーション パスで現在表示されているページ。

PathSeparator 3

サイト マップのナビゲーション パスの区切り記号。 SiteMapPath コントロールの既定の区切り記号は、">" 文字です。

次の例では、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 コントロールによって管理されます。 次の一覧では、使用可能なノードの種類について説明します。

  • 現在表示されているページを表す 1 つのノード。

  • サイト ナビゲーション階層の最上位ノードである 1 つのノード。

  • 最上位ノードと現在のノード (親ノード) の間の 0 個以上のノード。

  • サイト ナビゲーション パスの区切り記号を表す 0 個以上のノード。

各ノードは、PathSeparator 型のノードを除き、基になる SiteMapNodeにデータ バインドされます。

適用対象

こちらもご覧ください