Dynamic CSS

Today I was in need of changing the css file for some pages in a MVC3 project.
Still I want to keep the layout page with a default css (overwritten in case there is another one for that page)
I've read several complex solutions, but then I thought: "that can't be right"
I mean, it is something too simple to use a whole nuget for that.

Did some tests, and it worked.
There are only 2 simple steps.

1: change your _layout page to this:

<link href="@Url.Content(ViewBag.Css ?? "~/Content/Site.css")" rel="stylesheet" type="text/css" />

2: in the pages you want to change the css files, simply do

ViewBag.Css = "~/Content/OtherSite.css";

Easy, right?


Writing JavaScript is awesome.
It is so simple, yet powerful. And if you add jQuery, it just makes me happy!

But there is a problem in here. There is no compiler for JavaScript, once I spent over 4 hours over a bug to find a 'd' character lost in one of the files.
Not today. Today I got this:


It will be in every single  site I do from now on.
And I strongly recommend you do the same.

This is not the only option, you can look for others, but most of them are online analyzers, and I think this one is easier to run, you just have to link it (and jQuery, silly)

<script src="jquery.js"></script>
<script src="jquery.lint.js"></script>
easy as Π 
Got it?