Dynamically change imported/linked stylesheet

J

JezB

How can I dynamically change an external stylesheet link (or import) at
runtime in server-side code ?

I don't want to use a placeholder as in

<link id="myTheme" rel="stylesheet" type="text/css"
href="<%=CurrentTheme%>">

because this requires that I declare a public string (CurrentTheme) in every
page. I want to do it more transparently, to work with any page that links
(or imports) an external stylesheet.

Any ideas ?
 
G

GSK

How about registering your link as a generic control, then changing the
value of the href attribute?

i.e. <link id="myTheme" rel="stylesheet" type="text/css" runat=server>

protected System.Web.UI.HtmlControls.HtmlGenericControl myTheme

myTheme.Attributes["href"] = CurrentTheme;

- gsk
http://www.meblogic.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top