SiteMapResolveEventArgs SiteMapResolveEventArgs SiteMapResolveEventArgs SiteMapResolveEventArgs Class

Definition

Stellt Daten für ein Ereignis bereit, das durch einen Aufruf der CurrentNode-Eigenschaft der SiteMapProvider-Klasse ausgelöst wird.Provides data for an event that is raised by calling the CurrentNode property of the SiteMapProvider class.

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

Beispiele

Im folgenden Codebeispiel wird veranschaulicht, wie das SiteMapResolve -Ereignis auf einer ASP.NET-Webseite behandelt wird, um die Ziel-URLs zu ändern, die von einem site Navigations SiteMapPath Steuerelement wie dem-Steuerelement angezeigt werden.The following code example demonstrates how to handle the SiteMapResolve event on an ASP.NET Web page to modify the target URLs that are displayed by a site navigation control, such as the SiteMapPath control. In diesem Beispiel ist die aktuelle Seite eine Post-Seite in einem Online Bulletin Board oder-Forum.In this example, the current page is a post page in an online bulletin board or forum. Zum Rendering einer sinnvolleren Website Navigation werden die URLs der Knoten, die vom Navigations Steuerelement angezeigt werden, mit Abfrage Zeichenfolgen angehängt, die für den Kontext relevant sind.To render more meaningful site navigation, the URLs of the nodes displayed by the navigation control are appended with query strings that are relevant to the context.

Hinweis Der Zugriff auf die CurrentNode -Eigenschaft ist in der SiteMapResolveEventHandler -Klasse sicher.Note It is safe to access the CurrentNode property from within the SiteMapResolveEventHandler class. Die ASP.net-Site Navigations Infrastruktur schützt vor endlos Rekursion, in diesem Fall.The ASP.NET site navigation infrastructure guards against infinite recursion, in this case.

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

Hinweise

Die SiteMapResolveEventArgs -Klasse wird in der ResolveSiteMapNode -Methode verwendet, damit Abonnenten SiteMapResolve für das-Ereignis eine Instanz der SiteMapNode -Klasse zurückgeben können.The SiteMapResolveEventArgs class is used in the ResolveSiteMapNode method to enable subscribers to the SiteMapResolve event to return an instance of the SiteMapNode class. Indem Sie einen Ereignishandlerdelegaten SiteMapResolve hinzufügen, um das Ereignis SiteMapNode zu behandeln, können Sie eine Darstellung einer Seite erstellen, ohne einen benutzerdefinierten Site Übersichts Anbieter zu implementieren.By adding an event handler delegate to handle the SiteMapResolve event, you can create a SiteMapNode representation of a page without implementing a custom site map provider.

Konstruktoren

SiteMapResolveEventArgs(HttpContext, SiteMapProvider) SiteMapResolveEventArgs(HttpContext, SiteMapProvider) SiteMapResolveEventArgs(HttpContext, SiteMapProvider) SiteMapResolveEventArgs(HttpContext, SiteMapProvider)

Initialisiert mit den angegebenen HttpContext- und SiteMapProvider-Objekten eine neue Instanz der SiteMapResolveEventArgs-Klasse.Initializes a new instance of the SiteMapResolveEventArgs class using the specified HttpContext and SiteMapProvider objects.

Eigenschaften

Context Context Context Context

Ruft den Kontext der Seitenanforderung ab, den der angeforderte Knoten darstellt.Gets the context of the page request that the requested node represents.

Provider Provider Provider Provider

Ruft das SiteMapProvider-Objekt ab, das das SiteMapResolve-Ereignis ausgelöst hat.Gets the SiteMapProvider object that raised the SiteMapResolve event.

Methoden

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Bestimmt, ob das angegebene Objekt mit dem aktuellen Objekt identisch ist.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Fungiert als Standardhashfunktion.Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Ruft den Type der aktuellen Instanz ab.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Erstellt eine flache Kopie des aktuellen Object.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt.Returns a string that represents the current object.

(Inherited from Object)

Gilt für:

Siehe auch