Adding a new navigation node to sharepoint 2010 Top Navigation

六月ゝ 毕业季﹏ 提交于 2019-12-23 02:22:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!