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:
a. Open Visual Studio 2010.
b. Go to File => New => Project.
c. Select Console Application from the installed templates.
d. Enter the name and click on ok.
e. Replace Program.cs with the following code.
static void Main(string args)
using (SPSite siteCollection = new SPSite("http://servername:1111/sites/sample"))
using (SPWeb web = siteCollection.OpenWeb("Subsite3"))
f. Hit F5.
g. Go to the Subsite3, the top link bar looks like the following