Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    May 2005
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Serving ASP as CSS?

    Hi,

    I'm a front end designer/builder. With sites that run php, I use Patrick Fitzgerald's 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:
    Code:
    <?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,
    Will


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

  • #2
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    Regular Coder
    Join Date
    May 2005
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

    Thanks,
    Will

  • #4
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

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

  • #5
    Regular Coder
    Join Date
    May 2005
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks degsy. I have a project this week that I'll give it a try on.

    Big Preesh,
    Will


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •