View Full Version : Serving ASP as CSS?

03-22-2006, 06:17 PM

I'm a front end designer/builder. With sites that run php, I use Patrick Fitzgerald's (http://www.barelyfitz.com/projects/csscolor/) method of using variables to set css colors. It's simple to use and keeps colors consistent across 1500 line styles sheets.

It's a simple PHP method. Some sites I work on do not have PHP available, running asp or asp.net instead. I've only done a few formish things with asp.

Can some one tell me how to mimic this PHP behavior:
<?php header("Content-type: text/css"); ?>

The process is simple. make style sheet, save it as styles.php and link to 'styles.php' as your stylesheet in the HTML document. That bit of code there tells the browser to actually serve it as CSS, not PHP. I'm sure there's an ASP equivalent but heck if I can find it.

Thanks much,

PS. If some one knows how to do it in coldfusion, I'd be sussed for the other third of sites. ;)

03-23-2006, 04:57 PM
If you just want to include the file then you don't need the header.

Just write out the CSS so that when outputted it will form a valid CSS/HTML document and you can include it into your pages.

03-23-2006, 06:59 PM
Thanks for the reply. It's a little more than an include, I actually need it to do some preprocessing.

The basic gist of the technique is to declare some color variables at the top of the document like
$bgcolor=#fff; $headers=#aac;

and then in the css write:
#newsdiv{background-color=<? $bgcolor ?>;}
h3{color=<? $headers ?>;}

might seem like more work but it really helps with consistency across large documents. So I need the server to process the variables and then serve it to the browser as css. In PHP anyway, it requires that header declaration. Maybe I'm just over thinking ASP?


03-24-2006, 12:08 PM
You can add a content header if you wish. I don't think you really need it.

The file is an ASP file so all the processing will be done before it is outputted to the browser.
The browser will just get the CSS/HTML

Response.AddHeader("content-type", "text/css")

03-27-2006, 09:44 PM
Thanks degsy. I have a project this week that I'll give it a try on.

Big Preesh,