Click here to Skip to main content
15,901,426 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
How to access Parameter within  @Url.Content("~/Content/" + "Theme1.css") javascript 


What I have tried:

function changetheme(Name) {

if (Name == "Theme1") {
var thestyle = document.getElementById("style");
thestyle.href = "@Url.Content("~/Content/" + "Theme1.css")";
}
}


instead on Theme1 in(@Url.Content("~/Content/" + "Theme1.css")) i want to use Name variable
Posted
Updated 16-Jun-16 21:35pm

1 solution

try this

HTML
<link id="themelink" href="~/Content/YourCurrentTheme.css" rel="stylesheet" />
<script>
    function changetheme(Name) {
        var thestyle = document.getElementById("themelink");
        var styleName = Name + '.css';
        var href = "@Url.Content("~/Content/")" + styleName;
        thestyle.href = href;
    }
</script>
 
Share this answer
 
Comments
Sathish km 17-Jun-16 4:52am    
Thanks man... easy & simple ...
Karthik_Mahalingam 17-Jun-16 5:01am    
welcome.
Sathish km 17-Jun-16 6:16am    
Sathish Chennai
Karthik_Mahalingam 17-Jun-16 6:19am    
Kabali daw :)
Sathish km 17-Jun-16 7:47am    
Sema.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900