muthukumar Durai

muthukumar Durai

  • NA
  • 20
  • 8.8k

hide top navigation child node in sharepoint 2013 using c#

Jan 14 2016 12:50 AM
private void HideTopNavigation()
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite Osite = new SPSite(SPContext.Current.Site.ID))
{
using (SPWeb Oweb = Osite.OpenWeb())
{
SPNavigationNodeCollection topNavNodes = Oweb.Navigation.TopNavigationBar;
foreach (SPNavigationNode node in topNavNodes)
{
if (node.Title == "Org Browser")
{
if (node.Children.Count > 0)
{
foreach (SPNavigationNode childNode in node.Children)
{
if (childNode.Title == "Official")
{
childNode.IsVisible = false;
using (SPSite oSite = new SPSite(SPContext.Current.Site.Url + childNode.Url))
{
using (SPWeb ospWeb = oSite.OpenWeb())
{
ospWeb.AllowUnsafeUpdates = true;
PublishingWeb oPub = PublishingWeb.GetPublishingWeb(ospWeb);
oPub.IncludeInCurrentNavigation = false;
oPub.Update();
ospWeb.Update();
ospWeb.AllowUnsafeUpdates = false;
}
}
Oweb.AllowUnsafeUpdates = true;
childNode.Update();
Oweb.AllowUnsafeUpdates = false;
}
}
}
}
}
}
}
});
}
 
 
i use this for hide that but it not working