Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am trying to hide the left nav on secondary pages in my SP 2010 pub site. I can do it just fine with an tag around the nav table, but then on the secondary pages it doesn't hold it's width when it does display. I put an image in there below the nav to hold the width and it does, but it does not disappear on any page with the . Any thoughts?

    <asp:ContentPlaceHolder ID="LeftNavTableCell" runat="server">
        <table cellpadding="0" cellspacing="0" id="LeftNav">
            <tr>
                <td style="width:301px; text-align:left; vertical-align:top; background-color:#daf1fe;">
    <div class="body-wrapper" style="left: 0px; top: 0px; ">
            <a name="startNavigation"></a>
                                                    <asp:ContentPlaceHolder id="PlaceHolderNavSpacer" runat="server" />
                <div id="s4-leftpanel" class="s4-notdlg">
                <div id="s4-leftpanel-content">
                    <asp:ContentPlaceHolder id="PlaceHolderLeftNavBarDataSource" runat="server" />
                    <asp:ContentPlaceHolder id="PlaceHolderCalendarNavigator" runat="server" />
                    <asp:ContentPlaceHolder id="PlaceHolderLeftActions" runat="server"></asp:ContentPlaceHolder>
                        <asp:ContentPlaceHolder id="PlaceHolderLeftNavBarTop" runat="server"/>
                    <asp:ContentPlaceHolder id="PlaceHolderLeftNavBar" runat="server">
            <div class="ms-quicklaunchouter">
            <div class="ms-quickLaunch">
            <asp:ContentPlaceHolder id="PlaceHolderQuickLaunchTop" runat="server">
            <SharePoint:UIVersionedContent UIVersion="3" runat="server">
                <ContentTemplate>
                    <h3 class="ms-standardheader"><label class="ms-hidden"><SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,quiklnch_pagetitle%>" EncodeMethod="HtmlEncode"/></label>
                    <Sharepoint:SPSecurityTrimmedControl runat="server" PermissionsString="ViewFormPages">
                        <div class="ms-quicklaunchheader"><SharePoint:SPLinkButton id="idNavLinkViewAll" runat="server" NavigateUrl="~site/_layouts/viewlsts.aspx" Text="<%$Resources:wss,quiklnch_allcontent%>" accesskey="<%$Resources:wss,quiklnch_allcontent_AK%>"/></div>
                    </SharePoint:SPSecurityTrimmedControl>
                    </h3>
                </ContentTemplate>
            </SharePoint:UIVersionedContent>
            </asp:ContentPlaceHolder>
            <Sharepoint:SPNavigationManager
            id="QuickLaunchNavigationManager"
            runat="server"
            QuickLaunchControlId="QuickLaunchMenu"
            ContainedControl="QuickLaunch"
            EnableViewState="false"
            CssClass="ms-quicklaunch-navmgr">
            <div>
                <SharePoint:DelegateControl runat="server"
                    ControlId="QuickLaunchDataSource">
                 <Template_Controls>
                    <asp:SiteMapDataSource
                    SiteMapProvider="SPNavigationProvider"
                    ShowStartingNode="False"
                    id="QuickLaunchSiteMap"
                    StartingNodeUrl="sid:1025"
                    runat="server"
                    />
                 </Template_Controls>
                </SharePoint:DelegateControl>
        <SharePoint:UIVersionedContent UIVersion="3" runat="server">
            <ContentTemplate>
                <SharePoint:AspMenu
                    id="QuickLaunchMenu"
                    runat="server"
                    DataSourceId="QuickLaunchSiteMap"
                    Orientation="Vertical"
                    StaticDisplayLevels="2"
                    ItemWrap="true"
                    MaximumDynamicDisplayLevels="0"
                    StaticSubMenuIndent="0"
                    SkipLinkText=""
                    CssClass="s4-die"
                    >
                    <LevelMenuItemStyles>
                        <asp:MenuItemStyle CssClass="ms-navheader"/>
                        <asp:MenuItemStyle CssClass="ms-navitem"/>
                    </LevelMenuItemStyles>
                    <LevelSubMenuStyles>
                        <asp:SubMenuStyle CssClass="ms-navSubMenu1"/>
                        <asp:SubMenuStyle CssClass="ms-navSubMenu2"/>
                    </LevelSubMenuStyles>
                    <LevelSelectedStyles>
                        <asp:MenuItemStyle CssClass="ms-selectednavheader"/>
                        <asp:MenuItemStyle CssClass="ms-selectednav"/>
                    </LevelSelectedStyles>
                </SharePoint:AspMenu>
            </ContentTemplate>
        </SharePoint:UIVersionedContent>
        <SharePoint:UIVersionedContent UIVersion="4" runat="server">
            <ContentTemplate>
                <SharePoint:AspMenu
                  id="V4QuickLaunchMenu"
                  runat="server"
                  EnableViewState="false"
                  DataSourceId="QuickLaunchSiteMap"
                  UseSimpleRendering="true"
                  UseSeparateCss="false"
                  Orientation="Vertical"
                  StaticDisplayLevels="2"
                  MaximumDynamicDisplayLevels="0"
                  SkipLinkText=""
                  CssClass="customLeft" />
            </ContentTemplate>
        </SharePoint:UIVersionedContent>
            </div>
            </Sharepoint:SPNavigationManager>
        <Sharepoint:UIVersionedContent runat="server" UIVersion="3">
            <ContentTemplate>
                <Sharepoint:SPNavigationManager
                id="TreeViewNavigationManager"
                runat="server"
                ContainedControl="TreeView"
                >
                  <table class="ms-navSubMenu1" cellpadding="0" cellspacing="0" border="0">
                    <tr>
                      <td>
                        <table class="ms-navheader" width="100%" cellpadding="0" cellspacing="0" border="0">
                          <tr>
                            <td nowrap="nowrap" id="idSiteHierarchy">
                              <SharePoint:SPLinkButton runat="server" NavigateUrl="~site/_layouts/viewlsts.aspx" id="idNavLinkSiteHierarchy" Text="<%$Resources:wss,treeview_header%>" accesskey="<%$Resources:wss,quiklnch_allcontent_AK%>"/>
                            </td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
                  <div class="ms-treeviewouter">
                    <SharePoint:DelegateControl runat="server" ControlId="TreeViewAndDataSource">
                      <Template_Controls>
                        <SharePoint:SPHierarchyDataSourceControl
                         runat="server"
                         id="TreeViewDataSource"
                         RootContextObject="Web"
                         IncludeDiscussionFolders="true"
                        />
                        <SharePoint:SPRememberScroll runat="server" id="TreeViewRememberScroll" onscroll="javascript:_spRecordScrollPositions(this);" style="overflow: auto;height: 400px;width: 150px; ">
                          <Sharepoint:SPTreeView
                            id="WebTreeView"
                            runat="server"
                            ShowLines="false"
                            DataSourceId="TreeViewDataSource"
                            ExpandDepth="0"
                            SelectedNodeStyle-CssClass="ms-tvselected"
                            NodeStyle-CssClass="ms-navitem"
                            NodeStyle-HorizontalPadding="2"
                            SkipLinkText=""
                            NodeIndent="12"
                            ExpandImageUrl="/_layouts/images/tvplus.gif"
                            CollapseImageUrl="/_layouts/images/tvminus.gif"
                            NoExpandImageUrl="/_layouts/images/tvblank.gif"
                          >
                          </Sharepoint:SPTreeView>
                        </Sharepoint:SPRememberScroll>
                      </Template_Controls>
                    </SharePoint:DelegateControl>
                  </div>
                </Sharepoint:SPNavigationManager>
            </ContentTemplate>
        </SharePoint:UIVersionedContent>
        <Sharepoint:UIVersionedContent runat="server" UIVersion="4">
            <ContentTemplate>
                <Sharepoint:SPNavigationManager
                id="TreeViewNavigationManagerV4"
                runat="server"
                ContainedControl="TreeView"
                CssClass="s4-treeView"
                >
                  <SharePoint:SPLinkButton runat="server" NavigateUrl="~site/_layouts/viewlsts.aspx" id="idNavLinkSiteHierarchyV4" Text="<%$Resources:wss,treeview_header%>" accesskey="<%$Resources:wss,quiklnch_allcontent_AK%>" CssClass="s4-qlheader" />
                      <div class="ms-treeviewouter">
                        <SharePoint:DelegateControl runat="server" ControlId="TreeViewAndDataSource">
                          <Template_Controls>
                            <SharePoint:SPHierarchyDataSourceControl
                             runat="server"
                             id="TreeViewDataSourceV4"
                             RootContextObject="Web"
                             IncludeDiscussionFolders="true"
                            />
                            <SharePoint:SPRememberScroll runat="server" id="TreeViewRememberScrollV4" onscroll="javascript:_spRecordScrollPositions(this);" style="overflow: auto;height: 400px;width: 155px; ">
                              <Sharepoint:SPTreeView
                                id="WebTreeViewV4"
                                runat="server"
                                ShowLines="false"
                                DataSourceId="TreeViewDataSourceV4"
                                ExpandDepth="0"
                                SelectedNodeStyle-CssClass="ms-tvselected"
                                NodeStyle-CssClass="ms-navitem"
                                SkipLinkText=""
                                NodeIndent="12"
                                ExpandImageUrl="/_layouts/images/tvclosed.png"
                                ExpandImageUrlRtl="/_layouts/images/tvclosedrtl.png"
                                CollapseImageUrl="/_layouts/images/tvopen.png"
                                CollapseImageUrlRtl="/_layouts/images/tvopenrtl.png"
                                NoExpandImageUrl="/_layouts/images/tvblank.gif"
                              >
                              </Sharepoint:SPTreeView>
                            </Sharepoint:SPRememberScroll>
                          </Template_Controls>
                        </SharePoint:DelegateControl>
                      </div>
                </Sharepoint:SPNavigationManager>
            </ContentTemplate>
        </SharePoint:UIVersionedContent>
            <asp:ContentPlaceHolder id="PlaceHolderQuickLaunchBottom" runat="server">
            <SharePoint:UIVersionedContent UIVersion="3" runat="server" id="PlaceHolderQuickLaunchBottomV3">
                <ContentTemplate>
                    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="s4-die">
                    <tbody>
                    <tr><td>
                    <table class="ms-recyclebin" width="100%" cellpadding="0" cellspacing="0" border="0">
                    <tbody>
                    <tr><td nowrap="nowrap">
                    <SharePoint:SPLinkButton runat="server" NavigateUrl="~site/_layouts/recyclebin.aspx" id="v3idNavLinkRecycleBin" ImageUrl="/_layouts/images/recycbin.gif" Text="<%$Resources:wss,StsDefault_RecycleBin%>" PermissionsString="DeleteListItems" />
                    </td></tr>
                    </table>
                    </td></tr>
                    </table>
                </ContentTemplate>
            </SharePoint:UIVersionedContent>
            <SharePoint:UIVersionedContent UIVersion="4" runat="server" id="PlaceHolderQuickLaunchBottomV4">
                <ContentTemplate>
                    <ul class="s4-specialNavLinkList">
                    </ul>
                </ContentTemplate>
            </SharePoint:UIVersionedContent>
            </asp:ContentPlaceHolder>
            </div>
            </div>
                    </asp:ContentPlaceHolder>
                </div>
            </div>

            </div>
    </td>
            </tr>
            <tr>
                <td><img src="../../Style Library/Images/whtDiv.gif" /></td>
            </tr>
        </table>
    </asp:ContentPlaceholder>

On the pagelayouts I don't want this on I have this:

<asp:Content ContentPlaceHolderId="LeftNavTableCell" runat="server"></asp:Content>

but the image still shows up.

share|improve this question

3 Answers 3

You can use a couple simple lines of CSS markup to hide the left panel. This will hide all left panel content (including the Quick Launch).

#s4-leftpanel {
  display: none;
}
.s4-ca {
  margin-left: 0px;
}
share|improve this answer

If that's a viable solution for you, you could reference a javascript framework like jQuery and hide the left nav by default by overriding 'display' CSS property of the left nav container with 'none' and setting it back to 'block' using conditional javascript calls like the following

 if (/\/Pages\/ShouldShowLeftNav\.aspx/i.test(location.href)) $(selector).show();
share|improve this answer

Here is a basic workaround to hide the left nav:

  1. Add or Edit a content editor web part.
  2. Add this text to the source view:

    .ms-navframe{ display:none; }

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.