Programmatically Modify Site-Map Nodes in Memory

G

Guest

First look at: http://msdn2.microsoft.com/en-us/library/ms178425(VS.80).aspx

I've tried this, and while the code sort of works, the modified SiteMapNodes
get stuck in memory and can't be modified on other requests without having to
kill the aspnet_wp manually.

ISSUE: I need to modify the URL and TITLE of the last link on the
SiteMapPath (breadcrumb) control. I have a parent page called "companies"
that displays a list of results. Clicking on a company should take you to
the "details" page passing along the ID on the querystring. Now, when you
get to the details page I need to append that ID on to the current node and
change the title to the name of the company.

Take a sample from the sitemap:

<siteMapNode url="Companies/default.aspx" title="Companies"
description="Companies">
<siteMapNode url="Companies/manage.aspx" title="Manage"
description="Manage"></siteMapNode>
<siteMapNode url="Companies/view.aspx" title="View"
description="View"></siteMapNode>
</siteMapNode>


When viewing the list the SiteMapPath renders correctly as:
Home / Companies

When I follow the MS example and when the user is on the details page the
control renders as:
Home / Companies / Company ABC [/Companies/view.aspx?id=123]

All looks good. But, when you go back to the list and select a different
company you end up with the same rendering even through the URL in the
broswer has the ID of the new company.

Home / Companies / Company ABC [/Companies/view.aspx?id=123]

should be

Home / Companies / Company XYZ [/Companies/view.aspx?id=789]

The only way I get the SiteMapPath to refresh correctly is to manually kill
the aspnet_wp and refresh the page. But then it's stuck on Company XYZ.

Also, if I make a change to the SiteMap file, changes are reflected until I
kill the aspnet_wp.

Environment: XP SP2 & VS.NET '05
 
G

Guest

<asp:SiteMapPath ID="ctrlBreadCrumbs" runat="server" EnableViewState="false"
PathSeparator="/" SkipLinkText="Skip Navigation"
RenderCurrentNodeAsLink="true"></asp:SiteMapPath>



public partial class Controls_Layout : System.Web.UI.MasterPage
{
protected override void OnInit(EventArgs e)
{
base.OnInit(e);

SiteMap.SiteMapResolve += new
SiteMapResolveEventHandler(this.ModifyBreadCrumbs);
}

private SiteMapNode ModifyBreadCrumbs(Object sender,
SiteMapResolveEventArgs e)
{
SiteMapNode currentNode = SiteMap.CurrentNode.Clone(true);
SiteMapNode tempNode = currentNode;

if (Context.Request.QueryString["id"] != null)
{
IOrganization org = this._objFactory.Organizations.Get(new
Guid(Context.Request.QueryString["id"].ToString()));

tempNode.Url = string.Format("{0}?{1}", tempNode.Url,
Context.Request.QueryString);
tempNode.Title = org.DisplayName;
}

return currentNode;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top