SiteMapNodeItemType 枚举

定义

SiteMapNodeItemType 控件使用 SiteMapPath 枚举来标识节点层次结构中 SiteMapNodeItem 节点的类型。

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

字段

名称 说明
Root 0

站点导航层次结构的顶部节点。 只能有一个根节点。

Parent 1

网站导航路径中当前已查看页面的父节点。 父节点是在根节点和导航层次结构中的当前节点之间找到的任何节点。

Current 2

网站导航路径中当前查看的页面。

PathSeparator 3

网站地图导航路径分隔符。 控件的默认分隔符 SiteMapPath 是“>”字符。

示例

以下示例演示如何在方法中创建SiteMapPath.OnItemCreatedSiteMapNodeItem方法后调用SiteMapPath.InitializeItem该方法。 此示例是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 类型的节点除外。

适用于

另请参阅