Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9208469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:37:29+00:00 2026-06-18T00:37:29+00:00

Hi guys I’ve read a lot of article and tutorials in the internet about

  • 0

Hi guys I’ve read a lot of article and tutorials in the internet about how to dynamically change the theme in MVC3. But it doesn’t seems to fit my need.

I’ve read this bunch of tutorials
http://www.codeproject.com/Articles/171695/Dynamic-CSS-using-Razor-Engine
http://kazimanzurrashid.com/posts/asp-dot-net-mvc-theme-supported-razor-view-engine
http://www.carlj.ca/2007/11/19/dynamically-applying-themes-to-your-aspnet-site-with-a-sitemap/
http://www.dotnetfunda.com/articles/article14.aspx
http://msdn.microsoft.com/en-us/library/tx35bd89.aspx
http://www.codeproject.com/Articles/18300/How-to-change-page-theme-in-asp-net-2-0-dynamicall
and a lot of more but doen’t fit my need T_T.

Problem: I want that my theme(style.css) to dynamically change from time to time without any click of buttons. It just spontaneously changing like lets say 30min for one theme to change to another one in a single page/view. (Actually I even don’t know if this is even possible)

So far I’m following this tutorial but seems not a complete approach.

My idea is this:
I want style.css in my _Layout to change to style2.css after 30 minutes then change again to style3.css after another 30 minutes then loop back again to style.css and so on. And where is the best way to do this approach? In the View? Controller? jquery? javascript? or whatsoever.

I will greatly appreciate any suggestions and answers here. Thanks in advance..

Edit2:
Currently I’ve gathered one solution from Juann Strauss which uses javascript which I think have the concept on it

<link rel="Stylesheet" href="@Url.Content("~/Content/style.css")" id="style" />
<script type="text/javascript">
function changetheme()
{
    alert('changing theme');
    var thestyle = document.getElementById("style");
    switch (thestyle.href)
    {
        case "@Url.Content("~/Content/style.css")":
            thestyle.href = "@Url.Content("~/Content/style2.css")";
            break;
        case "@Url.Content("~/Content/style2.css")":
            thestyle.href = "@Url.Content("~/Content/style3.css")";
            break;
        case "@Url.Content("~/Content/style3.css")":
            thestyle.href = "@Url.Content("~/Content/style.css")";
            break;
    }
}
setInterval(changetheme, (30 * 60 * 1000));

Problem: The case "@Url.Content("~/Content/style.css")": shows a green wavy line which says Syntax error in regular expression. How could I possibly fixed it?

I have this another solution but also seems not working… T_T

Codes:

<link rel="Stylesheet" href="@Url.Content("~/Content/style.css")" id="style" />
<script type="text/javascript">
function changetheme()
{
alert('changing theme');
var thestyle = document.getElementById("Site");
var href = '@Url.Content("~/")';

switch(thestyle) 
{
    case (href + '/Content/style.css'): (href + '/Content/style2.css');
        break;
    case (href + '/Content/style2.css'): (href + '/Content/style3.css');
        break;
    case (href + '/Content/style3.css'): (href + '/Content/style.css');
        break;
}
}

setInterval(changetheme, (30 * 60 * 10000 ));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:37:30+00:00Added an answer on June 18, 2026 at 12:37 am

    javascript. Create a function that changes your css source file and set its timeout to 30 minutes. This would work if the user stays on the page for 30 minutes.

    If you want this to happen as the user is browsing your site, you’re going to have to store the time the session started in a session variable and output the number of minutes since the last theme change as part of some dynamically-constructed javascript on the front-end.

    If this is not clear enough, tell me and I’ll write some code.

    EDIT: the code

    <link rel="Stylesheet" href="@Url.Content("~/Content/style.css")" id="style" />
    <script type="text/javascript">
        function changetheme()
        {
            alert('changing theme');
            var thestyle = document.getElementById("style");
            switch (thestyle.href)
            {
                case "@Url.Content("~/Content/style.css")":
                    thestyle.href = "@Url.Content("~/Content/style2.css")";
                    break;
                case "@Url.Content("~/Content/style2.css")":
                    thestyle.href = "@Url.Content("~/Content/style3.css")";
                    break;
                case "@Url.Content("~/Content/style3.css")":
                    thestyle.href = "@Url.Content("~/Content/style.css")";
                    break;
            }
        }
        setInterval(changetheme, (30 * 60 * 1000));
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Guys my question is very simple but I am confused about the theory behind
guys I tried a lot for this code but nothing come up for conversion
Guys, Im calling a JsonResult but the getJSON is sending a null parameter to
Guys Please help me to solve this floating problem.I tried different methods but anything
Guys. I use getpixel & getdata to retrieve data from the same pic.but some
guys i am thinking about one sorting method,it is called sleep sort #include <stdlib.h>
Guys, this probably will be fairly simple, but how am I able to find
Guys lease help me out I think I'm close, but I'm missing something. Background
Guys I have asked this question before but did not receive a single comment
Guys!! I'm really enthusiastic in learning django and learnt a bit on Django-1.2 but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.