Closed Thread Icon

Topic awaiting preservation: Changing stylesheets in ASP? Pages that link to <a href="https://ozoneasylum.com/backlink?for=12008" title="Pages that link to Topic awaiting preservation: Changing stylesheets in ASP?" rel="nofollow" >Topic awaiting preservation: Changing stylesheets in ASP?\

 
Author Thread
Rane
Bipolar (III) Inmate

From: Denmark
Insane since: Oct 2001

posted posted 01-21-2002 12:30

'afternoon

Earlier today, I've read Docs topic on the dhtmlboard called "changing styles on the fly" which i found very interesting. Now Im in the situation that i need to make a "change stylesheets" function on a webpage. The difference here is, that once I select another stylesheet from a dropdown menu - the current page should change AND the rest of the pages should keep the chosen stylesheet (until i choose a new one).

I've found out that there's 2 ways in ASP....cookies or Sessions. Cookies im not that fond of + users can have it disabled in their browser. I havent worked with Sessions a lot, but can anyone give me a few hints (maybe even chunks of code) how to create this function?


lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 01-21-2002 16:25

In most cases if cookies are disabled, then sessions won't work too. Unless the session ID is propagated in the address bar (which is too ugly!).

Now back to you...I never wrote ASP, but i'll get you ideas on how to make that:

1. allow the user to pick a new style.
2. reload the same page while having the new style applied and having a session variable registered, like: <% Session("page1.html")="file1.css"
3. same for everypage (as process n.2): change style and register/modify appropriate session variable.
4. on each page load just before the you pick the style, just test if the session is registered and has a value, if so then spit it the .css file name to the browser as:
<link rel=stylesheet href="<% Response.Write(Session("page1.html"))" type="text/css"%>
5. etc, etc..

Good luck,


InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 01-21-2002 17:45

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Rane
Bipolar (III) Inmate

From: Denmark
Insane since: Oct 2001

posted posted 01-22-2002 08:29

Thanks both of you

I made it work perfectly with the Sessions thingy. I did see the css.asp method mentioned on the www somewhere - altho im not quite sure I understand where the .asp?template=darkgrey leads to in the text/css document ? Usually you just have .text { font-size: 10px; etc.etc. } .header { ... } stuff in your css file. So how/where do you make template "sections" there?

Let me know if I should post the Sessions code here - for everyone to view. Could be someone would be interested in the fairly low amount of code it actually takes.

lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 01-22-2002 08:38

In your .css file, act as this:

css.css:

code:
<% template = Request.QueryString("template")
if template = "darkgray" then
%>
.body { ...., .... }
<%
elseif template="yellow" then
%>
// yellow
.body { ..., ....}
<%
endif
%>
// common css here
.xyz { ...., ...}




InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 01-22-2002 11:13

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Rane
Bipolar (III) Inmate

From: Denmark
Insane since: Oct 2001

posted posted 01-22-2002 11:41

Wouldnt that be a lot of info that needed to be stored in the database? I mean...a column for every property, right?

Btw. I worked it out with Sessions like this:

code:
<%
Response.Expires = -1
Response.Buffer = True

If Request.Form("css") <> "" Then
Session("UserCSS") = Request.Form("css")

Response.Redirect Request.ServerVariables("SCRIPT_NAME")
Response.End
End If
If Session("UserCSS") = "" Then Session("UserCSS") = "test.css"
%><HTML>
<HEAD>
<TITLE>untitled</TITLE>
<LINK HREF="<%= Session("UserCSS") %>" REL="stylesheet" TYPE="text/css">
</HEAD>

<body>

<FORM ACTION="#" METHOD="POST">
New style: <SELECT NAME="css" OnChange="this.form.submit();"><OPTION VALUE=""><OPTION VALUE="test.css">test<OPTION VALUE="test2.css">test2<OPTION VALUE="test3.css">test3</SELECT>
</FORM>




InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 01-22-2002 13:43

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

« BackwardsOnwards »

Show Forum Drop Down Menu