Remove sidebar on pages in Yoko theme

Topics: ASP.NET 2.0, Themes
Oct 2, 2012 at 2:33 AM
Edited Oct 2, 2012 at 3:37 AM

Can someone tell me what to change in this code to remove the sidebar on a page in the Yoko theme.  Or is there something else needed to accomplish this. Thank you.

This code is in the pages that I want to have no sidebar.
using System;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BlogEngine.Core;
using BlogEngine.Core.Web.Controls;

public partial class current_hikes : BlogBasePage
    protected void Page_Load(object sender, EventArgs e)
        PlaceHolder phSidebar = Master.FindControl("phSidebar") as PlaceHolder;
        if (phSidebar != null)
            phSidebar.Visible = false;


I put this in the master.cs


 protected void Page_PreRender(object sender, EventArgs e)
        if (phSidebar.Visible)
            Form1.Attributes.Add("class", "body");
            Form1.Attributes.Add("class", "body noSidebar");


This in master


  <asp:PlaceHolder ID="phSidebar" runat="server">
    <div id="sidebar">
        <blog:WidgetZone runat="server" ID="rightzone1" />


This in the css


form1.noSidebar #content{
Oct 2, 2012 at 9:49 PM

I am still struggling with this, I think I am close but have something not right, I would appreciate some assistance, thank you.

Oct 4, 2012 at 7:35 PM

Can anyone help me with this?

Oct 5, 2012 at 12:09 AM

I have been successful removing the sidebar but still need help with the css displaying across the entire page.  Anybody that can hel me with this?

Oct 5, 2012 at 1:45 PM

Hi Jerry, 

For the CSS in the example above targeting the body element with no sidebar, should the CSS not be something like this.

.body.noSidebar #content{

Oct 5, 2012 at 5:10 PM

Actually your other code displays more of the table and contents the the above code.  I just thought it would be easier in the future if I decide to change themes I wouldn't have to make the individual page changes, I have about 6 pages using the code now.  The above code doesn't seem to make the tables display wide enougth to show all the data.

I have other issues trying to get the ajax calendar contro to work on some forms, do you have any thought on calendar controls, or date pickers they are called.

Click on the date field in this form and see what I mean.

Thank you for helping me Andy.





Oct 5, 2012 at 7:36 PM

Hi Jerry, 

As you say, the above solution is better if you have a few pages (which you have) and more generic, but the CSS needs tweaking for use in different themes.

In the Yoko theme the content div is nested within a div having id main, which also has a width setting, it is that setting which is restricting the max width of content.

Taking that into account, the above CSS becomes:

.body.noSidebar #main, .body.noSidebar #content {

It's untested, but I think not far off the mark.

The date picker issue is also CSS related, it looks like there are highly specific rules being applied to tables which are overriding the date picker table styles.

I tested this by going to the page you mentioned using browser tools to adjust the styles of the date picker td's specifically and it displays fine.

The culprit here is probably in the stylesheet section headed "Post Tables" where the general table selectors are prefixed with #content, so any table that appears within the content section is liable to inherit these styles, you could possibly start by remove the #content and see what happens. I say see what happens because there may be some other reason why this has been styled so... it's a fair starting point.


Oct 5, 2012 at 11:15 PM

The above latest code works great Andy, I have given up on the date picker for now, I just switched it out for the free basic date picker, it has a license notice displayed that doesn't look very nice but to keep the forms working I'll use it for now.  

I'll update all my pages with no sidebar to use it, that way when I switch themes all I'll need to do is edit the css, master, and .cs to keep it working, a few less changes then all the pages without the sidebar.   Thank you for all your time and help with this, I do appreciate it very much.