SiteMapNodeItemType Énumération

Définition

L'énumération SiteMapNodeItemType est utilisée par le contrôle SiteMapPath pour identifier le type d'un nœud SiteMapNodeItem dans une hiérarchie de nœuds.

public enum class SiteMapNodeItemType
public enum SiteMapNodeItemType
type SiteMapNodeItemType = 
Public Enum SiteMapNodeItemType
Héritage
SiteMapNodeItemType

Champs

Current 2

Page actuellement affichée dans le chemin de navigation de site.

Parent 1

Nœud parent de la page actuellement affichée dans le chemin de navigation de site. Un nœud parent correspond à tout nœud situé entre le nœud racine et le nœud actuel dans la hiérarchie de navigation.

PathSeparator 3

Séparateur de chemin pour la navigation de plan de site. Le séparateur par défaut pour le contrôle SiteMapPath est le caractère « > ».

Root 0

Nœud supérieur dans la hiérarchie de navigation de site. Il ne peut y avoir qu'un seul nœud racine.

Exemples

L’exemple suivant montre comment appeler la SiteMapPath.OnItemCreated méthode après avoir créé une SiteMapNodeItem méthode dans la SiteMapPath.InitializeItem méthode. Cet exemple fait partie d’un exemple plus grand fourni pour la SiteMapPath classe.

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

Remarques

Le SiteMapPath contrôle gère ses informations de navigation de site sous la forme d’une collection d’objets SiteMapNodeItem . SiteMapNodeItem les objets représentent des types de SiteMapNode nœuds fonctionnellement différents. En conséquence, ils sont gérés par le SiteMapPath contrôle. La liste suivante décrit les types de nœuds disponibles :

  • Un nœud qui représente la page actuellement consultée.

  • Un nœud qui est le nœud supérieur de la hiérarchie de navigation de site.

  • Zéro ou plusieurs nœuds entre le nœud supérieur et le nœud actuel (nœuds parents).

  • Zéro ou plusieurs nœuds qui représentent des séparateurs de chemin de navigation de site.

Chaque nœud est lié aux données à un nœud sous-jacent SiteMapNode, à l’exception des nœuds du type PathSeparator.

S’applique à

Voir aussi