How to use session values in .CSS file?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all

I have created a stylesheet file (.css) and included in all my web form pages. This stylesheet contains colors and fonts for headings, text, body backgrounds, and for tables. And these colors will depend on the logged-in user. Means they may be different for different users. I am storing these values (getting from database) using sessions after the user logs successfully

Now my question is, how can I use these session values in my stylesheet page? Or is there is other way to use them

Can anyone have a solution for this

Thanks in advance..

K.V.Ravindra Kumar
 
Since CSS File are not executed, you cannot have any code inside them.
The Webserver will just return the file as is to the client. The client
(IE for ex) will make use of the file.

So if you need to display create the Style Sheet on the fly based on the
Data from the database.

You can define custom names in the Header section with Literal Controls
placed wherever you want to change them and then assign the value to the
Literal control's text property.

OR

You could define different style sheets for differnet users and link to
the file dynamically using the same technique mentioned above. The later
would be faster and easier to maintain.

Regards,

Trevor Benedict R
MCSD

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Thanks Trevor
I think the second one you specified would be a costlier one, because, we can't guess the no of users for the website. And creating one for each dynamically and calling that in all the files, I don't think is the easiest way

How do I do that using Literal Controls in header section? Please give me hint

And one more thing is I have tried creating the stylesheet in an .aspx file (instead of in .css file). And included this file using <LINK> tag as usual. But this doesn't work atall. Stylesheets are not applied. Is there anything I need to do in this case? Once I see adding a stylesheet in .aspx in <LINK> tag. But I forgot where I saw that. And I tried the same way. But didn't workout for me

Help me in this regard

Thanks & regards
K.V.Ravindra Kuma


----- Trevor Benedict R wrote: ----

Since CSS File are not executed, you cannot have any code inside them
The Webserver will just return the file as is to the client. The clien
(IE for ex) will make use of the file

So if you need to display create the Style Sheet on the fly based on th
Data from the database

You can define custom names in the Header section with Literal Control
placed wherever you want to change them and then assign the value to th
Literal control's text property

O

You could define different style sheets for differnet users and link t
the file dynamically using the same technique mentioned above. The late
would be faster and easier to maintain

Regards

Trevor Benedict
MCS

*** Sent via Devdex http://www.devdex.com **
Don't just participate in USENET...get rewarded for it
 
Hi Ravindra,
Generating a stylesheet once, or on changes, for the user and then
reference to it from the different pages is probably the most
efficient way to do it.

You could also make an aspx-page that outputs a stylesheet instead of
html and reference to it as if it were a ordinary css-file.

/Hugo
 
Idea. Warning - I've never tried it, but the more I think on it, I think it could turn out kinda nifty.

Ok, instead of using external CSS files, use internal CSS code at the top of each page. However, take this segment of code and make it an asp include, which then can use session variables, etc. Might be a little more server intensive than a straight .css file, but I'm thinking it'll do what you want it to just fine.

Input welcome... 'cause it's giving me some thoughts!
- Teros
 
Back
Top