Show subsite on top navigation

Showing subsite programmatically is not as straight forward as using the UI

Global navigation

I found out that this property is only available from PublishingWeb (instead of SPWeb object) which is contained in Microsoft.Sharepoint.Publishing.dll. By default VS 2010 does not include the dll in the reference. After adding the dll, use the code below to show sub sites

PublishingWeb publisher = PublishingWeb.GetPublishingWeb(myWeb);
                        
publisher.Navigation.GlobalIncludeSubSites = true;
publisher.Update();
publisher.Close();

            

Hope that helps

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: