Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Programmatically enable Show Subsites and Show Pages for Global navigation in SharePoint
WhatsApp
Vijai Anand Ramalingam
14y
22.9
k
0
0
25
Blog
I have a site collection with the
SharePoint Server Publishing Infrastructure feature
enabled on the site collection and sites with the
SharePoint Server Publishing
site feature activated.
Go to
Site Actions => Site Settings => Look and Feel => Navigation => Global Navigation
.
In the global navigation you could see the following options
Programmatically Enable/Disable Global Navigation Settings
using
(
SPSite
siteCollection =
new
SPSite
(
"http://servername:1111/sites/sample"
))
{
using
(
SPWeb
web = siteCollection.RootWeb)
{
PublishingWeb
publishingWeb =
PublishingWeb
.GetPublishingWeb(web);
// Global Navigation
//Show Subsites
publishingWeb.Navigation.GlobalIncludeSubSites =
false
;
//Show Pages
publishingWeb.Navigation.GlobalIncludePages =
false
;
// Maximum number of dynamic items to show within this level of navigation:
publishingWeb.Navigation.GlobalDynamicChildLimit = 60;
//Update the changes
publishingWeb.Update();
}
}
Programmatically enable Show Subsites and Show Pages for Global navigation in SharePoint
People also reading
Membership not found