问题
I am trying to add a new navigation node to Top Navigation bar in my sharepoint website and I am using the following code:
public void AddNavigation(SPWeb web, String url, string module, string key)
{
var resourceFile = "$Resources:" + module + "," + key;
UnregisterGlobalNavigationLink(web, url);
SPNavigationNode node = web.Navigation.GetNodeByUrl(url);
if (node != null && overrideGlobalNavigationSetting) return node;
node = new SPNavigationNode(resourceFile, url);
node = web.Navigation.TopNavigationBar.AddAsLast(node);**//Exception here**
}
But I am getting an exception that I don't know how to resolve:
An unexpected error occured while manipulating the navigational structure of this Web.
How can I solve this issue?
回答1:
If it is an external node you want to add a another parameter isExternal = true
to the node constructor, so it looks like this:
node = new SPNavigationNode(resourceFile, url, true);
EDIT: And by external I mean it points outside the site collection
来源:https://stackoverflow.com/questions/38049772/adding-a-new-navigation-node-to-sharepoint-2010-top-navigation