0

I'm designing an MVC site, and I've already got quite a few things in the Site.css that only apply to one controller or even one page. I'd like to break this out into multiple css files and include them only when necessary, but how can I do this when all header information is in the Site.Master.

Note: I still want to use master pages, I just want some header resources to be per page or per controller.

C. Ross
  • 28,735
  • 39
  • 139
  • 230

1 Answers1

5

I was able to do this by adding a ContentPlaceHolder into my Site.master header and then linking to the CSS statements via that placeholder. It works well from what I've seen.

Example:

<head runat="server">
  <title>Site Master</title>
  <asp:ContentPlaceHolder ID="css" runat="server" />
  <link href="~/css/css.css" type="text/css" rel="stylesheet" />
</head>

Something else to consider - if you have a lot of "one-off" CSS styles, you may want to think about how you're setting up the styles in the first place.

Community
  • 1
  • 1
JasCav
  • 33,714
  • 19
  • 103
  • 163