SiteMapResolveEventArgs Klasa

Definicja

Dostarcza dane dla zdarzenia, które jest wywoływane przez wywołanie CurrentNode właściwości SiteMapProvider klasy.

public ref class SiteMapResolveEventArgs : EventArgs
public class SiteMapResolveEventArgs : EventArgs
type SiteMapResolveEventArgs = class
    inherit EventArgs
Public Class SiteMapResolveEventArgs
Inherits EventArgs
Dziedziczenie
SiteMapResolveEventArgs

Przykłady

W poniższym przykładzie kodu pokazano, jak obsługiwać SiteMapResolve zdarzenie na ASP.NET stronie sieci Web w celu zmodyfikowania docelowych adresów URL wyświetlanych przez kontrolkę nawigacji witryny, taką jak kontrolka SiteMapPath . W tym przykładzie bieżąca strona jest stroną wpisową na forum lub tablicy biuletynów online. Aby renderować bardziej zrozumiałą nawigację po witrynie, adresy URL węzłów wyświetlanych przez kontrolkę nawigacji są dołączane do ciągów zapytania, które są istotne dla kontekstu.

Uwaga Dostęp do właściwości jest CurrentNode bezpieczny z poziomu SiteMapResolveEventHandler klasy . W tym przypadku infrastruktura nawigacji ASP.NET lokacji chroni przed nieskończoną rekursją.

private void Page_Load(object sender, EventArgs e)
{
    // The ExpandForumPaths method is called to handle
    // the SiteMapResolve event.
    SiteMap.SiteMapResolve +=
      new SiteMapResolveEventHandler(this.ExpandForumPaths);
}

private SiteMapNode ExpandForumPaths(Object sender, SiteMapResolveEventArgs e)
{
    // The current node represents a Post page in a bulletin board forum.
    // Clone the current node and all of its relevant parents. This
    // returns a site map node that a developer can then
    // walk, modifying each node.Url property in turn.
    // Since the cloned nodes are separate from the underlying
    // site navigation structure, the fixups that are made do not
    // effect the overall site navigation structure.
    SiteMapNode currentNode = SiteMap.CurrentNode.Clone(true);
    SiteMapNode tempNode = currentNode;

    // Obtain the recent IDs.
    int forumGroupID = GetMostRecentForumGroupID();
    int forumID = GetMostRecentForumID(forumGroupID);
    int postID = GetMostRecentPostID(forumID);

    // The current node, and its parents, can be modified to include
    // dynamic querystring information relevant to the currently
    // executing request.
    if (0 != postID)
    {
        tempNode.Url = tempNode.Url + "?PostID=" + postID.ToString();
    }

    if ((null != (tempNode = tempNode.ParentNode)) &&
        (0 != forumID))
    {
        tempNode.Url = tempNode.Url + "?ForumID=" + forumID.ToString();
    }

    if ((null != (tempNode = tempNode.ParentNode)) &&
        (0 != forumGroupID))
    {
        tempNode.Url = tempNode.Url + "?ForumGroupID=" + forumGroupID.ToString();
    }

    return currentNode;
}
Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

    ' The ExpandForumPaths method is called to handle
    ' the SiteMapResolve event.
    AddHandler SiteMap.SiteMapResolve, AddressOf Me.ExpandForumPaths

End Sub

Private Function ExpandForumPaths(ByVal sender As Object, ByVal e As SiteMapResolveEventArgs) As SiteMapNode
    ' The current node represents a Post page in a bulletin board forum.
    ' Clone the current node and all of its relevant parents. This
    ' returns a site map node that a developer can then
    ' walk, modifying each node.Url property in turn.
    ' Since the cloned nodes are separate from the underlying
    ' site navigation structure, the fixups that are made do not
    ' effect the overall site navigation structure.
    Dim currentNode As SiteMapNode = SiteMap.CurrentNode.Clone(True)
    Dim tempNode As SiteMapNode = currentNode

    ' Obtain the recent IDs.
    Dim forumGroupID As Integer = GetMostRecentForumGroupID()
    Dim forumID As Integer = GetMostRecentForumID(forumGroupID)
    Dim postID As Integer = GetMostRecentPostID(forumID)

    ' The current node, and its parents, can be modified to include
    ' dynamic querystring information relevant to the currently
    ' executing request.
    If Not (0 = postID) Then
        tempNode.Url = tempNode.Url & "?PostID=" & postID.ToString()
    End If

    tempNode = tempNode.ParentNode
    If Not (0 = forumID) And Not (tempNode Is Nothing) Then
        tempNode.Url = tempNode.Url & "?ForumID=" & forumID.ToString()
    End If

    tempNode = tempNode.ParentNode
    If Not (0 = ForumGroupID) And Not (tempNode Is Nothing) Then
        tempNode.Url = tempNode.Url & "?ForumGroupID=" & forumGroupID.ToString()
    End If

    Return currentNode

End Function

Uwagi

Klasa SiteMapResolveEventArgs jest używana w metodzie ResolveSiteMapNode , aby umożliwić subskrybentom zdarzenia SiteMapResolve zwrócenie wystąpienia SiteMapNode klasy. Dodając delegata programu obsługi zdarzeń do obsługi SiteMapResolve zdarzenia, można utworzyć reprezentację SiteMapNode strony bez implementowania niestandardowego dostawcy mapy witryny.

Konstruktory

SiteMapResolveEventArgs(HttpContext, SiteMapProvider)

Inicjuje SiteMapResolveEventArgs nowe wystąpienie klasy przy użyciu określonych HttpContext obiektów i SiteMapProvider .

Właściwości

Context

Pobiera kontekst żądania strony reprezentowanego przez żądany węzeł.

Provider

SiteMapProvider Pobiera obiekt, który wywołał SiteMapResolve zdarzenie.

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy

Zobacz też