views:

206

answers:

1

Can anyone see why this should not work:

SPSite topNavigationSite = new SPSite("http://moss");
SPWeb topNavigationWeb = topNavigationSite.OpenWeb();
SPNavigationNodeCollection topNavigationBarNodes = topNavigationWeb.Navigation.TopNavigationBar;
SPNavigationNode updateNode = topNavigationBarNodes.Navigation.GetNodeByUrl("/about");
updateNode.Url = "";
topNavigationWeb.Update();

I can see debugging that the url get's set to "" but when the page renders, the navigation still shows the url as /about/default.aspx

I'm running this in page_load and expected it to update the moss database with the new url value.

A: 

Have you tried:

updateNode.Update();
topNavigationWeb.Update();

It doesn't look like you are updating the SPNavigationNode object. (Note: you may not need the second Update call.)

Alex Angas
Alex, can I loop and see all the spnavigationnodes as I think now it may be set to "" and therefore I can't use GetNodeByUrl :)
78lro
@orl78: Yes, you should be able to do a `foreach` over the SPNavigationNodeCollection and examine the nodes.
Alex Angas