Assembly: System.Web (in System.Web.dll)
Public Delegate Function SiteMapResolveEventHandler ( sender As Object, e As SiteMapResolveEventArgs ) As SiteMapNode
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 NIB: Events and Delegates.
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.
It is safe to access the CurrentNode property from within the class. The ASP.NET site navigation infrastructure guards against infinite recursion, in this case.
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
Available since 2.0