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

SiteMapResolveEventHandler Delegate

Represents the method that will handle the SiteMapResolve event of a specific instance of the SiteMapProvider or static SiteMap class.

Namespace: System.Web
Assembly: System.Web (in system.web.dll)

public delegate SiteMapNode SiteMapResolveEventHandler (
	Object sender,
	SiteMapResolveEventArgs e
)
/** @delegate */
public delegate SiteMapNode SiteMapResolveEventHandler (
	Object sender, 
	SiteMapResolveEventArgs e
)
Not applicable.

Parameters

sender

The source of the event, an instance of the SiteMapProvider class.

e

A SiteMapResolveEventArgs that contains the event data.

Return Value

The SiteMapNode that represents the result of the SiteMapResolveEventHandler operation.

The static SiteMap class exposes the SiteMapResolve event of the default site map provider.

When you create a SqlDataSourceCommandEventHandler delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see Events and Delegates.

TopicLocation
How to: Programmatically Modify Site-Map Nodes in MemoryBuilding ASP .NET Web Applications
How to: Programmatically Modify Site-Map Nodes in MemoryBuilding ASP .NET Web Applications

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. In order to render more meaningful site navigation, the URLs of the nodes that are displayed by the navigation control are appended with query strings that are relevant to the context.

NoteNote:

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;
}

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.