Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Stefan Ekman 18 posts 37 karma points
    Sep 15, 2011 @ 18:01
    Stefan Ekman
    0

    Prevent CSS to be applied to some custom content

    Hi,

    In a section of my site I want to create pages with results from competetions and those are usually with a lot of styling, tables etc in them and I would like the content not to be affected by the MasterPages CSS file at all. Is there any way to do this or do I have to create a new master template from scratch for those pages?

    Thanks,

    Stefan

  • Tom Hare 49 posts 81 karma points
    Sep 21, 2011 @ 16:33
    Tom Hare
    0

    Hi Stefan,

    I guess you could wrap the <link> tag for your master CSS file in an if statement and tell it to exclude the appropriate page/document type/template?

    Tom

  • Nicolas 26 posts 46 karma points
    Sep 23, 2011 @ 19:50
    Nicolas
    0

    Tom Hare has a good solution. But if you still need parts of your master CSS, you could add class or IDs to the objects that you want to specify the CSS, and them set new style. If I'm not making a mistake, those CSS style should have priority over general CSS style. Or last solution : you can split your master CSS file.

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Sep 23, 2011 @ 21:02
    Dan Diplo
    0

    Just put the CSS link HTML into a ContentPlaceHolder and then "blank it out" in the template you don't want to use it in by adding a Content tag. Remember, a Content tag replaces the content within a ContenPlaceHolder, and that includes blank content.

    For example, if you had this in your main master template:

    <head>
      <asp:contentplaceholder id="ContentPlaceHolderHead" runat="server">
        <link rel="stylesheet" href="/css/default.css" />
      </asp:contentplaceholder>
    </head>

    You could remove the <link rel="stylesheet" ... /> in any child template that inherits from the master by placing an empty asp:Content holder that references the ContentPlaceHolder id:

    <asp:Content ContentPlaceHolderID="ContentPlaceHolderHead" runat="server" />
Please Sign in or register to post replies

Write your reply to:

Draft