
Untitled
By: a guest on
Apr 24th, 2012 | syntax:
None | size: 1.08 KB | hits: 27 | expires: Never
How to change theme dynamically in mvc3
<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)
<select>
<option onclick="loadjscssfile("@Url.Content("~/Content/Site1.css")")">Theme1</option>
<option onclick="loadjscssfile("@Url.Content("~/Content/Site2.css")")">Theme2</option>
</select>
ViewModel.Title -> ViewBag.Title
ViewModel.Message -> ViewBag.Message
ViewModel.PasswordLength -> ViewBag.PasswordLength
return new ViewEngineResult(CreateView(controllerContext, viewPath, masterPath), this, incompletMatch); -> return new ViewEngineResult(CreateView(controllerContext, viewPath, masterPath), this);
<body class="red|blue">
//your content
</body>
.red{
background-color: red;
}
.blue{
background-color: blue;
}