Home All Groups Group Topic Archive Search About
Author
6 Dec 2006 10:40 PM
John H Clark
I want to vary the URL in a SiteMapNode between my development system and my
live system.  The SiteMapResolve example in the documentation clones the
current node then operates on it and returns the cloned node to the system.

This has no effect on the URL in the TreeView.

Does anyone have a suggestion on how to replace an URL with a new URL using
SiteMapResolve?

--
John H Clark
www.weownit.coop

Author
7 Dec 2006 9:27 AM
Steven Cheng[MSFT]
Hello John,

From your description, you have a sitemap file which will be displayed
through a TreeView on a page. However, since the actual url will differ
when deploying on different machine, you're wondering how to custoimze the
url of each sitemap node, correct?

As for this scenario, I've performed some research and ever tried the
following approachs:

1. Inspect the SiteMapDataSource control, find that the SiteMapDataSource
simply query SiteMapNodes from the SiteMapProvider, so the key is in the
siteMapProvider.

2. In SiteMapProvider, it has by default expose an "SiteMapResolve" event.
However, this event is raised when it try mapping the SiteMapNode that
matchs the current page's url. Therefore, it won't work for all
SiteMapNodes that will be displayed in TreeView.

Currently, what I can get are:

1) Override the built-in XmlSiteMapProvider and use our own provider. There
are some methods that can be override in the XmlSiteMapProvider class. You
can use reflector tool to inspect its code logic.

2) Also, another simpler means is hook the TreeView's TreeNodeDataBound
event and customize each Node's NavigationUrl there. e.g.

==========================

protected void TreeView1_TreeNodeDataBound(object sender, TreeNodeEventArgs
e)
    {
        e.Node.NavigateUrl += "&myparam=" + e.Node.GetHashCode();
    }
========================

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.