Include or link to Stylesheet

M

Mark

Hi - in my current pages, I have:

<link href="styles.css" rel="stylesheet" type="text/css">

What I would like to do is:
<!--#include file="config.asp" -->
<!--#include file="styles.asp" -->

config.asp read values from a database, which are used to populate
colours within the styles.asp sheet - for example, styles.asp looks
like:

<style type="text/css">
<!--
a, a:visited { color: <%=acolour%> }
a:hover { colour: <%=ahovcolour%> }
body, td, p {font-size: <%=fontsize%>; color: <%=fontcol%> }
-->
</style>

So, depending on user settings, values read from config.asp will be used
to populate the style sheet which is included in-line, and not
referenced by a link.

Is this a practical way of achieveing different user specific settings
for the same pages?

Is there a reason one way or the other why I shouldn't do it this way?
Is there a better way of giving people a way to customize colours and
other styles for their account?

Thanks for any help.

Mark
 
A

Aaron [SQL Server MVP]

There's a third option you didn't mention.

<link rel=stylesheet href=styles.asp?userid=whatever></link>

Where styles.asp goes to the database and returns a style sheet...
 
M

Mark

Hi - so are you talking about the asp page building the output, like:

'
get recordset
'

strCSS=strCSS & "a, a:visited{color:" & rsCSS("acolor") & "}"
strCSS=strCSS & "a:hover{color:" & rsCSS("hovercolor") & "}"

...and so on?

Thanks, Mark
 
A

Aaron [SQL Server MVP]

I think it will be easier to do it this way;

<%
' get recordset
' populate variables, like
acolor = rsCSS("acolor")
%>
a, a:visited{color:<%=acolor%>}

That way your CSS file can still look basically the same, and you won't have
to add all the style blocks that DON'T change (surely not every single class
you define is dependent on the database).
 
A

Aaron [SQL Server MVP]

I think it will be easier to do it this way;

<%
' get recordset
' populate variables, like
acolor = rsCSS("acolor")
%>
a, a:visited{color:<%=acolor%>}

That way your CSS file can still look basically the same, and you won't have
to add all the style blocks that DON'T change (surely not every single class
you define is dependent on the database).
 
C

Chris Hohmann

Aaron said:
I think it will be easier to do it this way;

<%
' get recordset
' populate variables, like
acolor = rsCSS("acolor")
%>
a, a:visited{color:<%=acolor%>}

That way your CSS file can still look basically the same, and you won't have
to add all the style blocks that DON'T change (surely not every single class
you define is dependent on the database).

To add to what Aaron has said, you could also create a static default
stylesheet and use the data-driven stylesheet to override on an as\-needed
basis. That way the default stylesheet can potentially benefit from caching.
It also eliminates the need for "filler' data for users who have not
specified custom styling options.
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top