Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting variable then call in css

Status
Not open for further replies.

derwent

Programmer
May 5, 2004
428
GB
I have set up an asp page to use as a stylesheet and all works great using cookies to determine the output in the css.

I need to set another variable to change the colour if on a certain page, the variable is set on the page itself

<%
'var to tell nav file which to highlight
strPage = "ssearch"
%>

then called in the asp stylesheet

if strpage = "ssearch" then
navcurrentcol = "000000"
studenthover = "000000"
else
navcurrentcol = "cc0000"
studenthover = "ffffff"
end if

But it won't work with just variables, will I need to use cookies for this page also or is there a way to get it to work with variables?
 
Err...why not just use the ASP code to output a differant classname, then define that classname in your CSS rather than re-use an existing one? Or just use <style> tags in the head section?

One of the advantages of using a CSS file rather than inline style is that when you visit a site you only need to download the styles once, then they are applied across the whole site. If you are going to rebuild the stylesheet every time the page loads, your actually going to be forcing your visitors to download more content instead of less. The easiest method to handle this would probably be to continnue to have all of the CSS that doesn't change from page to page in the file. Then place the CSS that does change in a <style> section. it's more complicated this way to maintain, but it means you won't be forcing extra downloads on your client each page load (if there browser is even willing to load another copy of the stylesheet and not use an old one from a previous page).

Personally I would just use differant classnames for the few elements that have to look differant, leave the stylesheet static and have it only downloaded once, and call it a day.

-T

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top