Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 24th, 2012  |  syntax: None  |  size: 1.08 KB  |  hits: 27  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to change theme dynamically in mvc3
  2. <script type="text/javascript">
  3.     function loadjscssfile(filename) {
  4.         var fileref = document.createElement("link")
  5.         fileref.setAttribute("rel", "stylesheet")
  6.         fileref.setAttribute("type", "text/css")
  7.         fileref.setAttribute("href", filename)
  8.     }
  9.     if (typeof fileref != "undefined")
  10.         document.getElementsByTagName("head")[0].appendChild(fileref)
  11.        
  12. <select>
  13.         <option onclick="loadjscssfile("@Url.Content("~/Content/Site1.css")")">Theme1</option>
  14.         <option onclick="loadjscssfile("@Url.Content("~/Content/Site2.css")")">Theme2</option>
  15.         </select>
  16.        
  17. ViewModel.Title -> ViewBag.Title
  18. ViewModel.Message -> ViewBag.Message
  19. ViewModel.PasswordLength -> ViewBag.PasswordLength
  20.  
  21. return new ViewEngineResult(CreateView(controllerContext, viewPath, masterPath), this, incompletMatch); -> return new ViewEngineResult(CreateView(controllerContext, viewPath, masterPath), this);
  22.        
  23. <body class="red|blue">
  24.     //your content
  25. </body>
  26.        
  27. .red{
  28.     background-color: red;
  29. }
  30.  
  31. .blue{
  32.     background-color: blue;
  33. }