我繼承了SharePoint 2007的網站,我的工作將其遷移到SharePoint 2010,我重新編譯使用2010 .DLL文件功能,接收器和我遇到了以下錯誤:替換爲Sharepoint的publishingWeb.currentNavigationNodes方法?
'Microsoft.SharePoint.Publishing.PublishingWeb' does not contain a definition for 'CurrentNavigationNodes' and no extension method 'CurrentNavigationNodes' accepting a first argument of type 'Microsoft.SharePoint.Publishing.PublishingWeb' could be found (are you missing a using directive or an assembly reference?)
在2007年的SharePoint, CurrentNavigationNodes是Microsoft.SharePoint.Publishing.PublishingWeb的一個屬性。顯然,這是移動到另一個類,或者被另一種獲取節點列表的方式替換。我無法弄清楚。任何人都知道這樣做的新方法是什麼?
下面是相關一塊2007代碼:
// set references to site, web, publishing site, publishing web
SPWeb thisWeb = (SPWeb)properties.Feature.Parent;
SPSite thisSite = thisWeb.Site;
PublishingSite thisPubSite = new PublishingSite(thisSite);
PublishingWeb thisPubWeb = PublishingWeb.GetPublishingWeb(thisWeb);
// enable tree view
thisWeb.TreeViewEnabled = true;
thisWeb.Update();
// navigation settings
thisPubWeb.InheritGlobalNavigation = true;
thisPubWeb.InheritCurrentNavigation = false;
thisPubWeb.IncludePagesInNavigation = true;
thisPubWeb.IncludeSubSitesInNavigation = true;
thisPubWeb.NavigationShowSiblings = false;
// clear current navigation (thrice needed to get everything)
SPNavigationNodeCollection navNodes = thisPubWeb.CurrentNavigationNodes;
foreach (SPNavigationNode thisNavNode in navNodes)
{
navNodes.Delete(thisNavNode);
}
foreach (SPNavigationNode thisNavNode in navNodes)
{
navNodes.Delete(thisNavNode);
}
foreach (SPNavigationNode thisNavNode in navNodes)
{
navNodes.Delete(thisNavNode);
}
thisPubWeb.Update();
你的答案有點不對。 SP 2010沒有SPWeb.Navigation.CurrentNavigationNodes,但它在SPWeb.Navigation上具有以下屬性:SPWeb.Navigation.QuickLaunch和SPWeb.Navigation.TopNavigationBar。 – marisks 2011-04-28 08:24:08