Despite setting the properties “UseShared” for SPWeb object to “True”, it does not show the correct Parent’s Global Navigation nodes.
I have this requirement where the subsites (3rd level, where 1st level being the root web) in second level web (which is also inheriting from root web) needs to display the global navigation nodes.
After trying
[sourcecode]
mySubSite.Navigation.UseShared = true;
[/sourcecode]
it does not show the actual parent’s global navigation, instead, it shows “[Portal Name]” which redirect to root web’s home page. If you go to “Site Settings” > “Navigation” and click “Save” button, it will subsequently show the correct nodes. Meaning, doing it in UI is fine but doing it programmatically is NOT OKAY!.
After digging into the Microsoft.SharePoint.Publishing.dll. I found this is the workaround.
[sourcecode]
Microsoft.SharePoint.Publishing.Navigation.WebNavigationSettings settings = new Microsoft.SharePoint.Publishing.Navigation.WebNavigationSettings(web);
settings.GlobalNavigation.Source = Microsoft.SharePoint.Publishing.Navigation.StandardNavigationSource.InheritFromParentWeb;
settings.Update();
<pre>[/sourcecode]
This will then make the subsite showing the correct one.