As a very simple solution we modified the master page to not show quick launch but again we was informed about a requirement where the user group want to do this in only some of the pages and not in all pages of the site using that master page. So after working on this for some time we have managed to do this via page UI using content editor webpart and also programmatically. we am sharing both the ways here. An important point to note here is the CSS classes you are using in your master page to display quick navigation. If you are using different CSS classes then you need to use them instead of what we am using here.

In the below section we will explain how to do this with page UI and content editor webpart.


1. identify the CSS classes

The first step will be to identify the CSS classes used by quick launch. Hence open the site in SharePoint designer.

2. Master page

Navigate down to the master page you are using. You do not need to check it out or to do any kind of editing. In the split mode just select the quick launch part and this in turn will select the code portion.Note down the CSS classes from here.

3. Hide quick launch

Now open the page that is using this master page and you want to hide this quick launch.

4. Edit page

Edit the page and add a content editor webpart. In the source editor add the following script. If you have different CSS classes then you need to use the same for them.

.leftNav1, .leftNav2, .leftNav3
 display: none;

Thats it the page is now without quick launch. In the next section we am showing how to do this via object model. we have hard coded the script but as we have already mentioned above you need to change it according to your master page. Hence instead of embedding it within the code you can take this as an input string as well. we have displayed some messages to give an idea of exactly what inputs are needed while running this application.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebPartPages;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI;
using Microsoft.SharePoint.Publishing;
using System.Xml;
namespace HideQuickLaunch
 class Program
 static void Main(string[] args)
 Console.WriteLine("This will hide the quick launch of a page");
 Console.WriteLine("Please enter the full URL of the page");
 String page = Console.ReadLine();
 String webPartName = String.Empty;
 using (SPSite site = new SPSite(page))
 using (SPWeb web = site.OpenWeb())
 String pageRelativeUrl = page.Remove(0, web.Url.Length+1);
 ContentEditorWebPart contentEditor = new ContentEditorWebPart();
 contentEditor.Title = String.Empty;
 PublishingWeb webPublish = PublishingWeb.GetPublishingWeb(web);
 PublishingPage pagePublish = webPublish.GetPublishingPages()[pageRelativeUrl];
 SPWebPartCollection webPartCollection = web.GetWebPartCollection(page, Storage.Shared);
 ContentEditorWebPart webPartToBeEdited = (ContentEditorWebPart) webPartCollection[contentEditor.StorageKey];
 XmlDocument xmlDoc = new XmlDocument();
 XmlElement elementContent = xmlDoc.CreateElement("script");
 elementContent.InnerText = "<style>\n.leftNav\n{\ndisplay:none;\n}\n.leftNav1, .leftNav2, .leftNav3\n{\ndisplay: none;\n}\n</style>";
 webPartToBeEdited.Content = elementContent;
 webPartToBeEdited.AllowHide = true;
 webPartToBeEdited.Hidden = true;
 Console.WriteLine("The quick launch is hidden now");