SiteMapNodeItemType Enumeração

Definição

A SiteMapNodeItemType enumeração é usada pelo SiteMapPath controlo para identificar o tipo de nó SiteMapNodeItem dentro de uma hierarquia de nós.

public enum class SiteMapNodeItemType
public enum SiteMapNodeItemType
type SiteMapNodeItemType = 
Public Enum SiteMapNodeItemType
Herança
SiteMapNodeItemType

Campos

Name Valor Description
Root 0

O nó superior da hierarquia de navegação do local. Só pode haver um nó raiz.

Parent 1

Um nó pai da página atualmente vista no caminho de navegação do site. Um nó pai é qualquer nó que se encontra entre o nó raiz e o nó atual na hierarquia de navegação.

Current 2

A página atualmente vista no caminho de navegação do site.

PathSeparator 3

Um separador de caminho de navegação no mapa do sítio. O separador padrão do SiteMapPath controlo é o carácter ">".

Exemplos

O exemplo seguinte demonstra como chamar o SiteMapPath.OnItemCreated método depois de criar um SiteMapNodeItem dentro do método SiteMapPath.InitializeItem . Este exemplo faz parte de um exemplo mais amplo fornecido à SiteMapPath turma.

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

Observações

O SiteMapPath controlo gere a informação de navegação do local como uma coleção de SiteMapNodeItem objetos. SiteMapNodeItem Os objetos representam tipos funcionalmente diferentes de SiteMapNode nós. Assim, são geridos pelo SiteMapPath controlo. A lista seguinte descreve os tipos de nós disponíveis:

  • Um nó que representa a página atualmente vista.

  • Um nó que é o nó superior da hierarquia de navegação do site.

  • Zero ou mais nós entre o nó superior e o nó atual (nós pais).

  • Zero ou mais nós que representem separadores de caminho de navegação do local.

Cada nó está ligado aos dados a um subjacente SiteMapNode, exceto os nós do tipo PathSepillar.

Aplica-se a

Ver também