asp.net - Switch css files dynamically -
i trying switch css files dynamically in asp.net using c#.
when click on button1/ button2 code working fine , css file switching on/off, when open page css deactivated.
when refresh page css file deactivated.
example> home (deafault) ! ! contact
when click on about us
, page opens, css file becomes deactivated , default 1 activated.
i want css file not deactivated if click on about us
after switching css file.
please advise me.
below code have written in master page
<head> <link id="lnkcss" runat="server" href = "~/css/main-style.css.css" rel="stylesheet" type="text/css" /> </head> <form> <asp:button id="button1" runat="server" text="css 1" onclick="changecss" commandargument="theme1.css" /> <asp:button id="button2" runat="server" text="css 2" onclick="changecss" commandargument="theme2.css" /> </form>
below code have written
protected void changecss(object sender, eventargs e) { lnkcss.attributes["href"] = "~/css/" + (sender button).commandargument; }
regards
you need perform post (or partial) retain selected css. allow other pages load selected css on default.
Comments
Post a Comment