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 SiteMapPath.InitializeItem方法SiteMapNodeItem中创建后, 如何调用方法。The following example demonstrates how to call the SiteMapPath.OnItemCreated method after creating a SiteMapNodeItem within the SiteMapPath.InitializeItem method. 此示例是为SiteMapPath类提供的更大示例的一部分。This 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

注解

控件将其站点导航信息作为SiteMapNodeItem对象的集合进行管理。 SiteMapPathThe SiteMapPath control manages its site navigation information as a collection of SiteMapNodeItem objects. SiteMapNodeItem对象表示功能不同的SiteMapNode节点类型。SiteMapNodeItem objects represent functionally different types of SiteMapNode nodes. 相应地, 这些SiteMapPath控件由控件管理。Accordingly, 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.

适用于

另请参阅