Dynamically change imported/linked stylesheet

  • Thread starter Thread starter JezB
  • Start date Start date
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 ?
 
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
 
Back
Top