Search This Blog

Friday, April 18, 2014

We can easily hide / show the Quick Launch in SharePoint 2010


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