Search This Blog

Tuesday, February 24, 2015

Customizing Sharepoint Site by Disabling/ Removing the Quick Launch Items

We can programmatically hide or remove the Quick Launch items from within a SharePoint Site to give that site a customized look and feel.

We can easily hide / show the Quick Launch items using the QuickLaunchEnabled property of a SPWeb object..

/*1st code block*/
SPSite spSite = new SPSite(SiteUrl);
SPWeb spWeb = spSite.OpenWeb();
spWeb.QuickLaunchEnabled = false;
spWeb.Update();

Similarly, we can iterate through each of the Quick Launch items to delete them from the web.

/*2nd code block*/
SPSite spSite = new SPSite(SiteUrl);
SPWeb spWeb = spSite.OpenWeb();
int i;
for (i = spWeb.Navigation.QuickLaunch.Count - 1; i > 0;  i--)
{
    spWeb.Navigation.QuickLaunch.Delete(spWeb.Navigation.QuickLaunch[ i ]);
}
spWeb.Update();


No comments:

Post a Comment