0

I have a MasterPage that is two column layout, left column menu, right column content. The whole page is XHTML/Divs/CSS layout. So the columns are div's with CSS applied to size them.

For one page, a grid page, I want only one column (the content column) to be 100% width for maximum viewing area.

How can I use the same masterpage and the same theme on this one off exception page?

Creating a whole new masterpage and adding a new CSS property to the theme just for this one page seems like overkill. Is there a way to override the content div's CSS width property on just this page? I'm not an expert in CSS but I thought there was a way to do this.

I do have some reservations about letting the client side do overriding though; for compatibility reasons. I would prefer a server side override.

Any suggestions?

1
  • I think the way to solve this painlessly is to add another content region that acts as a one column. That div can have the style that has 100% width. I'll post with results. Commented Jun 11, 2009 at 3:22

4 Answers 4

1

Give each page a distinct CSS class in code, and target that class in your CSS. Here is a stupid-simple way to accomplish it:

Create your own MasterPage class:

class MyMasterPage : MasterPage
{
    public string BodyClass {get;set;}
}

In your Master Page:

<%@ Master Inherits="MyNamespace.MyMasterPage" %>
...
<body class="<% =this.BodyClass %>">
    <asp:ContentPlaceHolder ... />
</body>
...

And in the codebehind of your page:

void Page_Load(object sender, EventArgs e)
{
    ((MyMasterPage)Master).BodyClass = "specialpage";
}

And in your CSS class:

.specialpage .mainColumn {width:100%;}
.specialpage .otherColumn {display:none;}
Sign up to request clarification or add additional context in comments.

1 Comment

Interesting. However I'd have to change all of the pages to accommodate an exception. I don't have any requirements beyond this page to apply a different style to a shared div based on page. Gave me an idea though.
0

You can use something similar to:

#content {
    /* Some styles */
    width: 100% !important;
}

1 Comment

I take that this is how you override on the client?
0

Worked like a charm. Solution to this is to add another region to the masterpage with a new div that has the 100% width CSS assigned to it. Also create a new style entry in your CSS file. On the content page put the content you want to be 100% width in the region that has the style for 100% and not in the one that corresponds with the two column layout.

After that it's just a matter setting the content page to either use the masterpage content of the content page content.

MasterPage:

<!-- start page -->
<div id="page">
    <!-- start content -->
     <div id="contentOneColumn" >
      <asp:ContentPlaceHolder ID="ContentPlaceHolderContentOneColumn" runat="server">
      <!-- content that needs 100% width, one column -->
     </asp:ContentPlaceHolder>
     </div>     
    <div id="content" >
        <asp:ContentPlaceHolder ID="ContentPlaceHolderContent" runat="server">
        <!-- content that works with two column -->
        </asp:ContentPlaceHolder>

CSS:

/* Content */

content {
    float: right;
    width: 600px;
}

/* ContentOneColumn */
contentOneColumn {
    float:none;
    width: 850px;
}

Comments

0

Use OnPreRenderComplete event, like this:

protected override void OnPreRenderComplete(EventArgs e)
    {
        base.OnPreRenderComplete(e);
        rfv_login.CssClass = "ValidatorReset";
        rfv_pwd.CssClass = "ValidatorReset";
    }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.