Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

SiteMapResolveEventArgs Class

Provides data for an event that is raised by calling the CurrentNode property of the SiteMapProvider class.

System.Object
  System.EventArgs
    System.Web.SiteMapResolveEventArgs

Namespace:  System.Web
Assembly:  System.Web (in System.Web.dll)
public class SiteMapResolveEventArgs : EventArgs

The SiteMapResolveEventArgs type exposes the following members.

  NameDescription
Public methodSiteMapResolveEventArgsInitializes a new instance of the SiteMapResolveEventArgs class using the specified HttpContext and SiteMapProvider objects.
Top
  NameDescription
Public propertyContextGets the context of the page request that the requested node represents.
Public propertyProviderGets the SiteMapProvider object that raised the SiteMapResolve event.
Top
  NameDescription
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

The SiteMapResolveEventArgs class is used in the ResolveSiteMapNode method to enable subscribers to the SiteMapResolve event to return an instance of the SiteMapNode class. 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.

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 this example, the current page is a post page in an online bulletin board or forum. 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.

Note   It is safe to access the CurrentNode property from within the SiteMapResolveEventHandler class. 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;
}

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.