Rick Good
Rick Good

Reputation: 59

Changing CSS based on variable

In ASP I wish to pass in a variable and based on that variable use different external CSS sheets. Is there a way to do this since it seems passing in a variable is done in the Body and caling in external style sheet is done in the header. Thanks.

Upvotes: 0

Views: 76

Answers (1)

Derrick Dennis
Derrick Dennis

Reputation: 148

I'd check for the variable in the header, then include the css files based on that.

select case request("Style")
    case "one"
    %>
        <link rel="stylesheet" href="/css/one.css" type="text/css" />
    <%
    case "two"
    %>
        <link rel="stylesheet" href="/css/two.css" type="text/css" />
    <%
    case else
    %>
        <link rel="stylesheet" href="/css/default.css" type="text/css" />
    <%
end select

I occasionally include css includes within the body too - it's dirty but works in all modern browsers.

Upvotes: 1

Related Questions