I want to change the theme of my web page on user selection I am using MVC3. My idea is to include various style sheets inside the Content folder and let the _layout.cshtml file decide which css file to call on user selection At present all i can do is include a single tag which is reflected on all the pages I want the view to be the same but the style sheets should change on selection.
I tried this code inside _Layout.cshtml:
<script type="text/javascript">
function loadjscssfile(filename) {
var fileref = document.createElement("link")
fileref.setAttribute("rel", "stylesheet")
fileref.setAttribute("type", "text/css")
fileref.setAttribute("href", filename)
}
if (typeof fileref != "undefined")
document.getElementsByTagName("head")[0].appendChild(fileref)
Inside Body tag:
<select>
<option onclick="loadjscssfile("@Url.Content("~/Content/Site1.css")")">Theme1</option>
<option onclick="loadjscssfile("@Url.Content("~/Content/Site2.css")")">Theme2</option>
</select>
But this also does not work:( Please help me.I am new to MVC3...