Style sheet from a recordset

M

Mark

Hi - I want to allow users of an intranet application, to select their
own colours etc.

So I have a tbale in my database, which has fields called bgcolour,
fontcolour etc. As I want all pages to get the users colours, I have an
includes file at the top of each page:

<!--#include file="userconfig.asp" -->

This is:

<%
BGColour="#FFFFFF"
FontColour="#000000"
...recordset...
if not EOR.Recordset
BGColour=Recordset("BGColour")
FontColour=Recordset("FontColour")
End if
%>

Now I would like my style sheet to pick up these values, so I have put:

body {
background-color: <%=BGColour%>;
color: <%=FontColour%>
}

...and so on.

I include my style sheet in the normal way, so I have the following at
the top of each page:

<!--#include file="userconfig.asp" -->
<link rel="stylesheet" href="styles.css">

Problem is, the value does not appear to be read by the style sheet. Is
there something I'm doing wrong?

Thanks, Mark
 
R

Ray Costanzo [MVP]

The file extension, .css, will not be processed by ASP.dll in a default IIS
setup. You could either map .css to asp.dll in IIS for your site, or rename
your style sheet to styles.asp so that it is processed. Warning: I believe
that these new-wave Mozilla browsers will not honor a style sheet that has a
..asp extension. This is totally asinine if it's true.

Ray at home
 
J

Jeff Cochran

Hi - I want to allow users of an intranet application, to select their
own colours etc.

So I have a tbale in my database, which has fields called bgcolour,
fontcolour etc. As I want all pages to get the users colours, I have an
includes file at the top of each page:

<!--#include file="userconfig.asp" -->

This is:

<%
BGColour="#FFFFFF"
FontColour="#000000"
..recordset...
if not EOR.Recordset
BGColour=Recordset("BGColour")
FontColour=Recordset("FontColour")
End if
%>

Now I would like my style sheet to pick up these values, so I have put:

body {
background-color: <%=BGColour%>;
color: <%=FontColour%>
}

..and so on.

I include my style sheet in the normal way, so I have the following at
the top of each page:

<!--#include file="userconfig.asp" -->
<link rel="stylesheet" href="styles.css">

Problem is, the value does not appear to be read by the style sheet. Is
there something I'm doing wrong?

Trying to process a CSS file in an ASP engine for one. :)

To do this, you'll need to include the style sheet as an ASP include.
It's an embedded style sheet in the ASP include file, not an included
style sheet. So instead of your styles.css you'd have a styles.asp:

<%
Response.Write "<style>"
Response.Write "body {"
Response.Write "background-color: "
Response.Write <%=BGColour%> & ";"
Response.Write "color: " & <%=FontColour%>
Response.Write "}"
Response.Write "</style>"
%>

Naturally, inlcude it in the head...

Jeff
 

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
474,161
Messages
2,570,891
Members
47,423
Latest member
henerygril

Latest Threads

Top