In this article we will be seeing about top link bar inheritance in SharePoint using object model. I have a site collection and three subsites (Subsite1, Subsite2 and Subsite3). In the Subsite3 I am going to inherit the navigation links from the parent site top link bar. Top Link Bar Inheritance: The sub site can inherit the navigation links from the parent site top link bar. When you create a site through user interface (Go to Site Actions => More Options => Site => Select the template), in the right hand side you could see an option "More options". In that you could see Navigation Inheritance section, by default no is selected. If you choose yes the navigation links from the parent site top link bar will be inherited. Programmatically inherit top link bar:
namespace TopLinkBarInheritance { class Program { static void Main(string[] args) { using (SPSite siteCollection = new SPSite("http://servername:1111/sites/sample")) { using (SPWeb web = siteCollection.OpenWeb("Subsite3")) { web.Navigation.UseShared=true; } } } }
}
Hit F5.
Go to the Subsite3, the top link bar looks like the following
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: