SiteMapNodeItemType Enum

Definition

Uppräkningen SiteMapNodeItemType används av SiteMapPath kontrollen för att identifiera typen av en SiteMapNodeItem nod i en nodhierarki.

public enum class SiteMapNodeItemType
public enum SiteMapNodeItemType
type SiteMapNodeItemType = 
Public Enum SiteMapNodeItemType
Arv
SiteMapNodeItemType

Fält

Name Värde Description
Root 0

Den översta noden i platsnavigeringshierarkin. Det kan bara finnas en rotnod.

Parent 1

En överordnad nod på sidan som visas i webbplatsnavigeringssökvägen. En överordnad nod är en nod som hittas mellan rotnoden och den aktuella noden i navigeringshierarkin.

Current 2

Den sida som visas i webbplatsnavigeringssökvägen.

PathSeparator 3

En avgränsare för navigeringssökväg för webbplatskarta. Standardavgränsaren SiteMapPath för kontrollen är tecknet ">".

Exempel

I följande exempel visas hur du anropar SiteMapPath.OnItemCreated metoden när du har skapat en SiteMapNodeItem i SiteMapPath.InitializeItem -metoden. Det här exemplet är en del av ett större exempel som tillhandahålls SiteMapPath för klassen.

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

Kommentarer

Kontrollen SiteMapPath hanterar webbplatsnavigeringsinformationen som en samling SiteMapNodeItem objekt. SiteMapNodeItem objekt representerar funktionellt olika typer av SiteMapNode noder. Därför hanteras de av SiteMapPath kontrollen. I följande lista beskrivs vilka typer av noder som är tillgängliga:

  • En nod som representerar den aktuella sidan.

  • En nod som är den översta noden i platsnavigeringshierarkin.

  • Noll eller fler noder mellan den översta noden och den aktuella noden (överordnade noder).

  • Noll eller fler noder som representerar webbplatsnavigeringssökvägsavgränsare.

Varje nod är databunden till en underliggande SiteMapNode, förutom noder av Typen PathSeparator.

Gäller för

Se även