CSS as a resource file

I just had a friend ask me "can you supply a css page as a streamed binary? like an img from a db?"  I have no idea.  He's thinking it could be a way to dynamically configure the output and solve browser bugs.  I'm not the best at output across differing browsers.  Any ideas?

Published Monday, June 28, 2004 12:05 PM by Keith Barrows
Filed under:

Comments

# re: CSS as a resource file

Monday, June 28, 2004 2:57 PM by Jerry Pisk
Of course you can. Server side code doesn't have to generate HTML, it can do anything, style sheets, images, text files, zip filkes, word documents, excel document, anything you want.

# re: CSS as a resource file

Monday, June 28, 2004 3:07 PM by Jon Galloway
Yep. Simpler than streaming binary, too, since CSS is just text (like HTML). So your css reference is just:

<link rel='StyleSheet' type='text/css' href='style.aspx'>

And style.aspx just writes out the appropriate css (from database, css file, etc.). Of course, the reference to style.aspx could be style.aspx?layout=printer&theme=simple.

# re: CSS as a resource file

Monday, June 28, 2004 3:39 PM by Phil Scott
If you go through Rory's archive's at neopoleon.com he threw some code together that accomplishes this task.

# re: CSS as a resource file

Tuesday, June 29, 2004 10:04 AM by Ben Tomkins
If you use XHTML doctypes with Mozilla and Mozilla is not given the correct MIME type for the CSS file it will refuse to load it.

Using an extension other than .css will cause issues in non IE browsers . . .

the solution is quite simple :o) you just have to inculde the following in the top of your referenced .aspx page:

<%@ Page Language="C#" ContentType="text/css" ResponseEncoding="iso-8859-1" %>

without including the ContentType as text/css is just does not work universally.

# re:CSS as a resource file

Sunday, April 10, 2005 7:07 AM by TrackBack
^_^,Pretty Good!

Leave a Comment

(required) 
(required) 
(optional)
(required)