Deshmukh
Deshmukh

Reputation: 29

Changing Themes Dynamically to a website in ASP.Net MVC website?

How to change themes of website upon change of drop down or a checkbox is checked, using Jquery? Is there a plug in?

Upvotes: 1

Views: 1472

Answers (2)

Sunil Kumar
Sunil Kumar

Reputation: 3242

You may try the below code for changing the Theme/Style of your webpage.

<link id="stylesheet" rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/le-frog/jquery-ui.css">

 //Handle this below code however you want
$("#stylesheet").attr({href : 'your css URL here'});

Check Fiddle Here.

Hope it helps you.. :)

Upvotes: 0

Eslam Soliman
Eslam Soliman

Reputation: 1296

Actually you want to change your style sheets which change your themes here is a snippet for that :

you may use a dynamic method like this for the style sheets :

function updateStyleSheet(filename) {

    newstylesheet = "Content/css/" + filename + ".css";
    if ($("#dynamic_css").length == 0) {
        $("head").append("<link>")
        css = $("head").children(":last");
        css.attr({
            id: "dynamic_css",
            rel: "stylesheet",
            type: "text/css",
            href: newstylesheet
        });
    } else {
        $("#dynamic_css").attr("href", newstylesheet);
    }

}

Upvotes: 1

Related Questions