Dynamically change imported/linked stylesheet

Discussion in 'ASP .Net' started by JezB, Jun 10, 2004.

  1. JezB

    JezB Guest

    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 ?
     
    JezB, Jun 10, 2004
    #1
    1. Advertisements

  2. JezB

    GSK Guest

    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
     
    GSK, Jun 10, 2004
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.