R – way to programmatically set the current node of a SiteMapPath control


My site has a few pages that point to the same child page. I'm using a xml site map that will not allow me to duplicate a SiteMapNode with the same Url. My idea was then to give my SiteMapPath control a parent node to populate itself from, and then add on a SiteMapNode of the current page.

Has anyone else had to do something similar? I've looked at this article http://msdn.microsoft.com/en-us/library/ms178425.aspx which describes how to "Programmatically Modify Site-Map Nodes in Memory" but they are including the SiteMapNode in the file and then just modifying that node by inspecting the querystring.

My node never exists, or if it is I'd need to copy it over to the correct parent so it could render the correct path. For a visual:

--My Page
----Page A
----Page B
----Page C
--My Other Page
----Page A
----Page D
----Page B
----Page C

Some examples of what I'd like to see:

Home > My Page > Page A
Home > My Other Page > Page A
Home > My Page > Page B
Home > YAPage > Page B

Best Solution

Looks like these are going to solve the problem:

http://www.codeproject.com/KB/aspnet/ABetterSiteMapResolve.aspx http://netpl.blogspot.com/2008/04/sitemapresolve-and-dynamic-site-map.html

For dynamic sitemaps: http://www.codeproject.com/KB/aspnet/dynamicsitemap.aspx

With multiple provider's you'll need to use this instead to attach the SiteMapResolve event: (If your event isn't firing most likely you don't have the correct provider set.)

SiteMap.Providers[currentProvider].SiteMapResolve += new SiteMapResolveEventHandler(Provider_SiteMapResolve);

Related Question