setting current state for a page with asp and css

D

dothvader

I have set up a "current" state with CSS for navigational links of a
website.

#nav a:link.current, #nav a:visited.current {background-
color:#800000;color:white;}
#nav a:hover.current {background-color:#800000; color:white;
cursor:default}

I am using asp to inlucde headers and footers with navigation. I want
to interface with CSS to show a current state for a current page. I
can do this with html ie.<a href="index.asp" class="current">Home</a>
but I have to use a static navigational bar which stays with the
page. I am not sure how to set this up with asp?

thanks
 
S

Stefan B Rusynko

Set up your class in the html page as a ASP variable
a href="index.asp" class="<%=className%>">
The use you server side code to change the style

<%
IF ..... THEN
className="current"
ELSE
className="someotherstylename "
END IF
%>

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


|I have set up a "current" state with CSS for navigational links of a
| website.
|
| #nav a:link.current, #nav a:visited.current {background-
| color:#800000;color:white;}
| #nav a:hover.current {background-color:#800000; color:white;
| cursor:default}
|
| I am using asp to inlucde headers and footers with navigation. I want
| to interface with CSS to show a current state for a current page. I
| can do this with html ie.<a href="index.asp" class="current">Home</a>
| but I have to use a static navigational bar which stays with the
| page. I am not sure how to set this up with asp?
|
| thanks
|
 
D

dothvader

Set up your class in the html page as a ASP variable
a href="index.asp" class="<%=className%>">
The use you server side code to change the style

<%
IF ..... THEN
className="current"
ELSE
className="someotherstylename "
END IF
%>

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


|I have set up a "current" state with CSS for navigational links of a
| website.
|
| #nav a:link.current, #nav a:visited.current {background-
| color:#800000;color:white;}
| #nav a:hover.current {background-color:#800000; color:white;
| cursor:default}
|
| I am using asp to inlucde headers and footers with navigation. I want
| to interface with CSS to show a current state for a current page. I
| can do this with html ie.<a href="index.asp" class="current">Home</a>
| but I have to use a static navigational bar which stays with the
| page. I am not sure how to set this up with asp?
|
| thanks
|

Ok, I understand the logic, but I was wondering if I could set up
somthing so that when asp reads a variable on a certain page it
triggers the current state of the navigation. In other words is there
a simpler way than an if then statement?

If the answer is no then I am having trouble with the exact wording
of the if then statement.

thanks
 
S

Stefan B Rusynko

The IF THEN is the simplest test for a single condition test

Say you have a ASP variable named "nextpagename" that is supposed to be "index.asp"
<%
IF nextpagename="index.asp" THEN
className="current"
ELSE
className="someotherstylename "
END IF
%>

then your html becomes
<a href="index.asp" class="<%=className%>">Home page</a>

If you still are having problems post a real variable from your page and the condition you are looking for
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


| > Set up your class in the html page as a ASP variable
| > a href="index.asp" class="<%=className%>">
| > The use you server side code to change the style
| >
| > <%
| > IF ..... THEN
| > className="current"
| > ELSE
| > className="someotherstylename "
| > END IF
| > %>
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > _____________________________________________
| >
| >
| > |I have set up a "current" state with CSS for navigational links of a
| > | website.
| > |
| > | #nav a:link.current, #nav a:visited.current {background-
| > | color:#800000;color:white;}
| > | #nav a:hover.current {background-color:#800000; color:white;
| > | cursor:default}
| > |
| > | I am using asp to inlucde headers and footers with navigation. I want
| > | to interface with CSS to show a current state for a current page. I
| > | can do this with html ie.<a href="index.asp" class="current">Home</a>
| > | but I have to use a static navigational bar which stays with the
| > | page. I am not sure how to set this up with asp?
| > |
| > | thanks
| > |
|
| Ok, I understand the logic, but I was wondering if I could set up
| somthing so that when asp reads a variable on a certain page it
| triggers the current state of the navigation. In other words is there
| a simpler way than an if then statement?
|
| If the answer is no then I am having trouble with the exact wording
| of the if then statement.
|
| thanks
|
 
D

dothvader

Ok, I tried setting up If Elseif but I don't have it correct I really
don't need another type of condition ie. className="someotherstylename
". It shoudl just default to my standard hyperlink class. This is
what I have -

<%
If currentpage="index.asp" Then
className="current"
ElseIf
If currentpage="test.asp" Then
className="current"
ElseIf
If currentpage="contact.asp" Then
className="current"
End If
%>

I then set up the trigger to -

<% currentpage = "test.asp" %>

I know this does not work so what am I missing?

thanks



The IF THEN is the simplest test for a single condition test

Say you have a ASP variable named "nextpagename" that is supposed to be "index.asp"
<%
IF nextpagename="index.asp" THEN
className="current"
ELSE
className="someotherstylename "
END IF
%>

then your html becomes
<a href="index.asp" class="<%=className%>">Home page</a>

If you still are having problems post a real variable from your page and the condition you are looking for
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


| > Set up your class in the html page as a ASP variable
| > a href="index.asp" class="<%=className%>">
| > The use you server side code to change the style
| >
| > <%
| > IF ..... THEN
| > className="current"
| > ELSE
| > className="someotherstylename "
| > END IF
| > %>
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > _____________________________________________
| >
| >
| > |I have set up a "current" state with CSS for navigational links of a
| > | website.
| > |
| > | #nav a:link.current, #nav a:visited.current {background-
| > | color:#800000;color:white;}
| > | #nav a:hover.current {background-color:#800000; color:white;
| > | cursor:default}
| > |
| > | I am using asp to inlucde headers and footers with navigation. I want
| > | to interface with CSS to show a current state for a current page. I
| > | can do this with html ie.<a href="index.asp" class="current">Home</a>
| > | but I have to use a static navigational bar which stays with the
| > | page. I am not sure how to set this up with asp?
| > |
| > | thanks
| > |
|
| Ok, I understand the logic, but I was wondering if I could set up
| somthing so that when asp reads a variable on a certain page it
| triggers the current state of the navigation. In other words is there
| a simpler way than an if then statement?
|
| If the answer is no then I am having trouble with the exact wording
| of the if then statement.
|
| thanks
|
 
T

Thomas A. Rowe

<%
If currentpage="index.asp" Then
className="current1"
ElseIf currentpage="test.asp" Then
className="current2"
ElseIf currentpage="contact.asp" Then
className="current3"
Else
className="current"
End If
%>

--
==============================================
Thomas A. Rowe
Microsoft MVP - FrontPage

http://www.Ecom-Data.com
==============================================


dothvader said:
Ok, I tried setting up If Elseif but I don't have it correct I really
don't need another type of condition ie. className="someotherstylename
". It shoudl just default to my standard hyperlink class. This is
what I have -

<%
If currentpage="index.asp" Then
className="current"
ElseIf
If currentpage="test.asp" Then
className="current"
ElseIf
If currentpage="contact.asp" Then
className="current"
End If
%>

I then set up the trigger to -

<% currentpage = "test.asp" %>

I know this does not work so what am I missing?

thanks



The IF THEN is the simplest test for a single condition test

Say you have a ASP variable named "nextpagename" that is supposed to be "index.asp"
<%
IF nextpagename="index.asp" THEN
className="current"
ELSE
className="someotherstylename "
END IF
%>

then your html becomes
<a href="index.asp" class="<%=className%>">Home page</a>

If you still are having problems post a real variable from your page and the condition you are
looking for
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________

message
| > Set up your class in the html page as a ASP variable
| > a href="index.asp" class="<%=className%>">
| > The use you server side code to change the style
| >
| > <%
| > IF ..... THEN
| > className="current"
| > ELSE
| > className="someotherstylename "
| > END IF
| > %>
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > _____________________________________________
| >
message| >
| > |I have set up a "current" state with CSS for navigational links of a
| > | website.
| > |
| > | #nav a:link.current, #nav a:visited.current {background-
| > | color:#800000;color:white;}
| > | #nav a:hover.current {background-color:#800000; color:white;
| > | cursor:default}
| > |
| > | I am using asp to inlucde headers and footers with navigation. I want
| > | to interface with CSS to show a current state for a current page. I
| > | can do this with html ie.<a href="index.asp" class="current">Home</a>
| > | but I have to use a static navigational bar which stays with the
| > | page. I am not sure how to set this up with asp?
| > |
| > | thanks
| > |
|
| Ok, I understand the logic, but I was wondering if I could set up
| somthing so that when asp reads a variable on a certain page it
| triggers the current state of the navigation. In other words is there
| a simpler way than an if then statement?
|
| If the answer is no then I am having trouble with the exact wording
| of the if then statement.
|
| thanks
|
 
D

dothvader

Getting closer but not there yet. I've played around with this and
still can't get it. I've set up a page so that you can see what I am
after:

http://trekwest.com/test.asp

Your suggestion put everthing into a "current" state. Also what about
the trigger <% currentpage = "test.asp" %> of identifying the page?

thanks again.

<%
If currentpage="index.asp" Then
className="current1"
ElseIf currentpage="test.asp" Then
className="current2"
ElseIf currentpage="contact.asp" Then
className="current3"
Else
className="current"
End If
%>

--
==============================================
Thomas A. Rowe
Microsoft MVP - FrontPage

http://www.Ecom-Data.com
==============================================


Ok, I tried setting up If Elseif but I don't have it correct I really
don't need another type of condition ie. className="someotherstylename
". It shoudl just default to my standard hyperlink class. This is
what I have -
<%
If currentpage="index.asp" Then
className="current"
ElseIf
If currentpage="test.asp" Then
className="current"
ElseIf
If currentpage="contact.asp" Then
className="current"
End If
%>
I then set up the trigger to -
<% currentpage = "test.asp" %>
I know this does not work so what am I missing?

The IF THEN is the simplest test for a single condition test
Say you have a ASP variable named "nextpagename" that is supposed to be "index.asp"
<%
IF nextpagename="index.asp" THEN
className="current"
ELSE
className="someotherstylename "
END IF
%>
then your html becomes
<a href="index.asp" class="<%=className%>">Home page</a>
If you still are having problems post a real variable from your page and the condition you are
looking for
--
_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________
message
| > Set up your class in the html page as a ASP variable
| > a href="index.asp" class="<%=className%>">
| > The use you server side code to change the style
| >
| > <%
| > IF ..... THEN
| > className="current"
| > ELSE
| > className="someotherstylename "
| > END IF
| > %>
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > _____________________________________________
| >
message| >
| > |I have set up a "current" state with CSS for navigational links of a
| > | website.
| > |
| > | #nav a:link.current, #nav a:visited.current {background-
| > | color:#800000;color:white;}
| > | #nav a:hover.current {background-color:#800000; color:white;
| > | cursor:default}
| > |
| > | I am using asp to inlucde headers and footers with navigation. I want
| > | to interface with CSS to show a current state for a current page. I
| > | can do this with html ie.<a href="index.asp" class="current">Home</a>
| > | but I have to use a static navigational bar which stays with the
| > | page. I am not sure how to set this up with asp?
| > |
| > | thanks
| > |
|
| Ok, I understand the logic, but I was wondering if I could set up
| somthing so that when asp reads a variable on a certain page it
| triggers the current state of the navigation. In other words is there
| a simpler way than an if then statement?
|
| If the answer is no then I am having trouble with the exact wording
| of the if then statement.
|
| thanks
|
 
T

Thomas A. Rowe

Here is an example of what I use to change the background and font color of links in a navigation
bar/table (I prefer to not use CSS):

The Menu style is specified on each page:

<%
MenuStyle = "B"
%>

The following is a ASP included inserted into all pages after the above MenuStyle:

<%
If MenuStyle = "A" then
CellBkgrd1 = "#CE0000"
FontColor1 = "#FFFFFF"
CellBkgrd2 = "#003897"
FontColor2 = "#FFFFFF"
CellBkgrd3 = "#CE0000"
FontColor3 = "#FFFFFF"
CellBkgrd4 = "#CE0000"
FontColor4 = "#FFFFFF"
CellBkgrd5 = "#CE0000"
FontColor5 = "#FFFFFF"
End If

If MenuStyle = "B" then
CellBkgrd1 = "#CE0000"
FontColor1 = "#FFFFFF"
CellBkgrd2 = "#CE0000"
FontColor2 = "#FFFFFF"
CellBkgrd3 = "#003897"
FontColor3 = "#FFFFFF"
CellBkgrd4 = "#CE0000"
FontColor4 = "#FFFFFF"
CellBkgrd5 = "#CE0000"
FontColor5 = "#FFFFFF"
End If

%>
==============================================
Thomas A. Rowe
Microsoft MVP - FrontPage

http://www.Ecom-Data.com
==============================================


dothvader said:
Getting closer but not there yet. I've played around with this and
still can't get it. I've set up a page so that you can see what I am
after:

http://trekwest.com/test.asp

Your suggestion put everthing into a "current" state. Also what about
the trigger <% currentpage = "test.asp" %> of identifying the page?

thanks again.

<%
If currentpage="index.asp" Then
className="current1"
ElseIf currentpage="test.asp" Then
className="current2"
ElseIf currentpage="contact.asp" Then
className="current3"
Else
className="current"
End If
%>

--
==============================================
Thomas A. Rowe
Microsoft MVP - FrontPage

http://www.Ecom-Data.com
==============================================


Ok, I tried setting up If Elseif but I don't have it correct I really
don't need another type of condition ie. className="someotherstylename
". It shoudl just default to my standard hyperlink class. This is
what I have -
<%
If currentpage="index.asp" Then
className="current"
ElseIf
If currentpage="test.asp" Then
className="current"
ElseIf
If currentpage="contact.asp" Then
className="current"
End If
%>
I then set up the trigger to -
<% currentpage = "test.asp" %>
I know this does not work so what am I missing?

The IF THEN is the simplest test for a single condition test
Say you have a ASP variable named "nextpagename" that is supposed to be "index.asp"
<%
IF nextpagename="index.asp" THEN
className="current"
ELSE
className="someotherstylename "
END IF
%>
then your html becomes
<a href="index.asp" class="<%=className%>">Home page</a>
If you still are having problems post a real variable from your page and the condition you are
looking for
--
_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________
| > Set up your class in the html page as a ASP variable
| > a href="index.asp" class="<%=className%>">
| > The use you server side code to change the style
| >
| > <%
| > IF ..... THEN
| > className="current"
| > ELSE
| > className="someotherstylename "
| > END IF
| > %>
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > _____________________________________________
| >
message| >
| > |I have set up a "current" state with CSS for navigational links of a
| > | website.
| > |
| > | #nav a:link.current, #nav a:visited.current {background-
| > | color:#800000;color:white;}
| > | #nav a:hover.current {background-color:#800000; color:white;
| > | cursor:default}
| > |
| > | I am using asp to inlucde headers and footers with navigation. I want
| > | to interface with CSS to show a current state for a current page. I
| > | can do this with html ie.<a href="index.asp" class="current">Home</a>
| > | but I have to use a static navigational bar which stays with the
| > | page. I am not sure how to set this up with asp?
| > |
| > | thanks
| > |
|
| Ok, I understand the logic, but I was wondering if I could set up
| somthing so that when asp reads a variable on a certain page it
| triggers the current state of the navigation. In other words is there
| a simpler way than an if then statement?
|
| If the answer is no then I am having trouble with the exact wording
| of the if then statement.
|
| thanks
|
 
D

dothvader

I appreciate your reply but I want to keep it simple. What I suggest
should work but I can't figure the logic.

thanks

Here is an example of what I use to change the background and font color of links in a navigation
bar/table (I prefer to not use CSS):

The Menu style is specified on each page:

<%
MenuStyle = "B"
%>

The following is aASPincluded inserted into all pages after the above MenuStyle:

<%
If MenuStyle = "A" then
CellBkgrd1 = "#CE0000"
FontColor1 = "#FFFFFF"
CellBkgrd2 = "#003897"
FontColor2 = "#FFFFFF"
CellBkgrd3 = "#CE0000"
FontColor3 = "#FFFFFF"
CellBkgrd4 = "#CE0000"
FontColor4 = "#FFFFFF"
CellBkgrd5 = "#CE0000"
FontColor5 = "#FFFFFF"
End If

If MenuStyle = "B" then
CellBkgrd1 = "#CE0000"
FontColor1 = "#FFFFFF"
CellBkgrd2 = "#CE0000"
FontColor2 = "#FFFFFF"
CellBkgrd3 = "#003897"
FontColor3 = "#FFFFFF"
CellBkgrd4 = "#CE0000"
FontColor4 = "#FFFFFF"
CellBkgrd5 = "#CE0000"
FontColor5 = "#FFFFFF"
End If

%>
==============================================
Thomas A. Rowe
Microsoft MVP - FrontPage

http://www.Ecom-Data.com
==============================================


Getting closer but not there yet. I've played around with this and
still can't get it. I've set up a page so that you can see what I am
after:

Your suggestion put everthing into a "current" state. Also what about
the trigger <% currentpage = "test.asp" %> of identifying the page?
thanks again.
<%
If currentpage="index.asp" Then
className="current1"
ElseIf currentpage="test.asp" Then
className="current2"
ElseIf currentpage="contact.asp" Then
className="current3"
Else
className="current"
End If
%>
--
==============================================
Thomas A. Rowe
Microsoft MVP - FrontPage
http://www.Ecom-Data.com
==============================================

Ok, I tried setting up If Elseif but I don't have it correct I really
don't need another type of condition ie. className="someotherstylename
". It shoudl just default to my standard hyperlink class. This is
what I have -
<%
If currentpage="index.asp" Then
className="current"
ElseIf
If currentpage="test.asp" Then
className="current"
ElseIf
If currentpage="contact.asp" Then
className="current"
End If
%>
I then set up the trigger to -
<% currentpage = "test.asp" %>
I know this does not work so what am I missing?
thanks
The IF THEN is the simplest test for a single condition test
Say you have aASPvariable named "nextpagename" that is supposed to be "index.asp"
<%
IF nextpagename="index.asp" THEN
className="current"
ELSE
className="someotherstylename "
END IF
%>
then your html becomes
<a href="index.asp" class="<%=className%>">Home page</a>
If you still are having problems post a real variable from your page and the condition you are
looking for
--
_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________
message
| > Set up your class in the html page as aASPvariable
| > a href="index.asp" class="<%=className%>">
| > The use you server side code to change the style
| >
| > <%
| > IF ..... THEN
| > className="current"
| > ELSE
| > className="someotherstylename "
| > END IF
| > %>
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > _____________________________________________
| >
message| >
| > |I have set up a "current" state with CSS for navigational links of a
| > | website.
| > |
| > | #nav a:link.current, #nav a:visited.current {background-
| > | color:#800000;color:white;}
| > | #nav a:hover.current {background-color:#800000; color:white;
| > | cursor:default}
| > |
| > | I am usingaspto inlucde headers and footers with navigation. I want
| > | to interface with CSS to show a current state for a current page. I
| > | can do this with html ie.<a href="index.asp" class="current">Home</a>
| > | but I have to use a static navigational bar which stays with the
| > | page. I am not sure how to set this up withasp?
| > |
| > | thanks
| > |
|
| Ok, I understand the logic, but I was wondering if I could set up
| somthing so that whenaspreads a variable on a certain page it
| triggers the current state of the navigation. In other words is there
| a simpler way than an if then statement?
|
| If the answer is no then I am having trouble with the exact wording
| of the if then statement.
|
| thanks
|
 
S

Stefan B Rusynko

That will result in a True or False result
<% currentpage = "test.asp" %>
means If it is then True (currentpage = "test.asp")
Else it is False (currentpage <> "test.asp")

That is the same as an IF Else statement

Your problem on your test page is
- you need the server to determine the page name
(ASP has no way of telling if "currentpage" is anything unless you add something to parse the page name)
- you need to use style classes that are defined in your style sheet
(only a default (no class) and "current" are defined)
- whatever you test for, one of the tests will alway be true hwmney your page name matched the on eyou are looking for

To add only the class named "current" to the current page (if it is named say test.asp), and not add a class to the other links
- all your links need to have unique server side code for the class for each link
(and you really only need to test for the one page you want to change the style on since you don't have multiuple styles)

Paste the below in your test page

<%
'Build links and set default styles (no class) for all pages
page1="index.asp"
page2="test.asp"
page3="contact.asp"
classname1=""
classname2=""
classname3=""

'Determine the page name of current page
PageURL = Request.ServerVariables("SCRIPT_NAME")
SearchChar = "/"
PagePos = InstrRev(PageURL, SearchChar)
IF PagePos>0 AND PagePos< Len(PageURL) THEN
currentPage = Lcase(Right(PageURL,Len(PageURL)-PagePos))
End If

'Set class for this pageX to classnameX
If currentPage=page2 Then classname2=classname2 & " class='current'"
'Change pageX and classnameX for each page you use the script on
%>

Then your links on all pages would be :

<div id="botnav">
<a href="index.asp"<%=classname1%>>Home</a>
<a href="test.asp"<%=classname2%>>Test</a>
<a href="contact.asp"<%=classname3%>>Contact Us</a>
</div>

PS
validate your CSS - you have style errors in it


--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


| Getting closer but not there yet. I've played around with this and
| still can't get it. I've set up a page so that you can see what I am
| after:
|
| http://trekwest.com/test.asp
|
| Your suggestion put everthing into a "current" state. Also what about
| the trigger <% currentpage = "test.asp" %> of identifying the page?
|
| thanks again.
|
| > <%
| > If currentpage="index.asp" Then
| > className="current1"
| > ElseIf currentpage="test.asp" Then
| > className="current2"
| > ElseIf currentpage="contact.asp" Then
| > className="current3"
| > Else
| > className="current"
| > End If
| > %>
| >
| > --
| > ==============================================
| > Thomas A. Rowe
| > Microsoft MVP - FrontPage
| >
| > http://www.Ecom-Data.com
| > ==============================================
| >
| >
| > | >
| > > Ok, I tried setting up If Elseif but I don't have it correct I really
| > > don't need another type of condition ie. className="someotherstylename
| > > ". It shoudl just default to my standard hyperlink class. This is
| > > what I have -
| >
| > > <%
| > > If currentpage="index.asp" Then
| > > className="current"
| > > ElseIf
| > > If currentpage="test.asp" Then
| > > className="current"
| > > ElseIf
| > > If currentpage="contact.asp" Then
| > > className="current"
| > > End If
| > > %>
| >
| > > I then set up the trigger to -
| >
| > > <% currentpage = "test.asp" %>
| >
| > > I know this does not work so what am I missing?
| >
| > > thanks
| >
| > >> The IF THEN is the simplest test for a single condition test
| >
| > >> Say you have a ASP variable named "nextpagename" that is supposed to be "index.asp"
| > >> <%
| > >> IF nextpagename="index.asp" THEN
| > >> className="current"
| > >> ELSE
| > >> className="someotherstylename "
| > >> END IF
| > >> %>
| >
| > >> then your html becomes
| > >> <a href="index.asp" class="<%=className%>">Home page</a>
| >
| > >> If you still are having problems post a real variable from your page and the condition you are
| > >> looking for
| > >> --
| >
| > >> _____________________________________________
| > >> SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > >> "Warning - Using the F1 Key will not break anything!" (-;
| > >> _____________________________________________
| >
| > >> message| >
| > >> | > Set up your class in the html page as a ASP variable
| > >> | > a href="index.asp" class="<%=className%>">
| > >> | > The use you server side code to change the style
| > >> | >
| > >> | > <%
| > >> | > IF ..... THEN
| > >> | > className="current"
| > >> | > ELSE
| > >> | > className="someotherstylename "
| > >> | > END IF
| > >> | > %>
| > >> | >
| > >> | > --
| > >> | >
| > >> | > _____________________________________________
| > >> | > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > >> | > "Warning - Using the F1 Key will not break anything!" (-;
| > >> | > _____________________________________________
| > >> | >
| > >> message| > >> | >
| > >> | > |I have set up a "current" state with CSS for navigational links of a
| > >> | > | website.
| > >> | > |
| > >> | > | #nav a:link.current, #nav a:visited.current {background-
| > >> | > | color:#800000;color:white;}
| > >> | > | #nav a:hover.current {background-color:#800000; color:white;
| > >> | > | cursor:default}
| > >> | > |
| > >> | > | I am using asp to inlucde headers and footers with navigation. I want
| > >> | > | to interface with CSS to show a current state for a current page. I
| > >> | > | can do this with html ie.<a href="index.asp" class="current">Home</a>
| > >> | > | but I have to use a static navigational bar which stays with the
| > >> | > | page. I am not sure how to set this up with asp?
| > >> | > |
| > >> | > | thanks
| > >> | > |
| > >> |
| > >> | Ok, I understand the logic, but I was wondering if I could set up
| > >> | somthing so that when asp reads a variable on a certain page it
| > >> | triggers the current state of the navigation. In other words is there
| > >> | a simpler way than an if then statement?
| > >> |
| > >> | If the answer is no then I am having trouble with the exact wording
| > >> | of the if then statement.
| > >> |
| > >> | thanks
| > >> |
|
|
 
D

dothvader

Eureka! The solution was so simple it finally hit me in the head.

Thank you for your brilliant and well thought out logic but it wasn't
neccessary. The key to this whole problem was a trigger or switch.
The only state to trigger was on every other case would be default. I
stumbled across the answer while working with the code you suggested.
The beauty is in it's simplcity and no if then statements.

In the current page you want to trigger the class as current you put
the following:

<% currentPage#="current" %>

then you set each link to correspond to that class:

<a href="index.asp" class="<%=currentPage1%>">Home</a>
<a href="test.asp" class="<%=currentPage2%>">Test</a>
<a href="contact.asp" class="<%=currentPage3%>">Contact Us</a>

See the results - http://trekwest.com/test.asp

praise god!


That will result in a True or False result
<% currentpage = "test.asp" %>
means If it is then True (currentpage = "test.asp")
Else it is False (currentpage <> "test.asp")

That is the same as an IF Else statement

Your problem on your test page is
- you need the server to determine the page name
(ASP has no way of telling if "currentpage" is anything unless you add something to parse the page name)
- you need to use style classes that are defined in your style sheet
(only a default (no class) and "current" are defined)
- whatever you test for, one of the tests will alway be true hwmney your page name matched the on eyou are looking for

To add only the class named "current" to the current page (if it is named say test.asp), and not add a class to the other links
- all your links need to have unique server side code for the class for each link
(and you really only need to test for the one page you want to change the style on since you don't have multiuple styles)

Paste the below in your test page

<%
'Build links and set default styles (no class) for all pages
page1="index.asp"
page2="test.asp"
page3="contact.asp"
classname1=""
classname2=""
classname3=""

'Determine the page name of current page
PageURL = Request.ServerVariables("SCRIPT_NAME")
SearchChar = "/"
PagePos = InstrRev(PageURL, SearchChar)
IF PagePos>0 AND PagePos< Len(PageURL) THEN
currentPage = Lcase(Right(PageURL,Len(PageURL)-PagePos))
End If

'Set class for this pageX to classnameX
If currentPage=page2 Then classname2=classname2 & " class='current'"
'Change pageX and classnameX for each page you use the script on
%>

Then your links on all pages would be :

<div id="botnav">
<a href="index.asp"<%=classname1%>>Home</a>
<a href="test.asp"<%=classname2%>>Test</a>
<a href="contact.asp"<%=classname3%>>Contact Us</a>
</div>

PS
validate your CSS - you have style errors in it

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


| Getting closer but not there yet. I've played around with this and
| still can't get it. I've set up a page so that you can see what I am
| after:
|
|http://trekwest.com/test.asp
|
| Your suggestion put everthing into a "current" state. Also what about
| the trigger <% currentpage = "test.asp" %> of identifying the page?
|
| thanks again.
|
| > <%
| > If currentpage="index.asp" Then
| > className="current1"
| > ElseIf currentpage="test.asp" Then
| > className="current2"
| > ElseIf currentpage="contact.asp" Then
| > className="current3"
| > Else
| > className="current"
| > End If
| > %>
| >
| > --
| > ==============================================
| > Thomas A. Rowe
| > Microsoft MVP - FrontPage
| >
| >http://www.Ecom-Data.com
| > ==============================================
| >
| >
| >| >
| > > Ok, I tried setting up If Elseif but I don't have it correct I really
| > > don't need another type of condition ie. className="someotherstylename
| > > ". It shoudl just default to my standard hyperlink class. This is
| > > what I have -
| >
| > > <%
| > > If currentpage="index.asp" Then
| > > className="current"
| > > ElseIf
| > > If currentpage="test.asp" Then
| > > className="current"
| > > ElseIf
| > > If currentpage="contact.asp" Then
| > > className="current"
| > > End If
| > > %>
| >
| > > I then set up the trigger to -
| >
| > > <% currentpage = "test.asp" %>
| >
| > > I know this does not work so what am I missing?
| >
| > > thanks
| >
| > >> The IF THEN is the simplest test for a single condition test
| >
| > >> Say you have a ASP variable named "nextpagename" that is supposed to be "index.asp"
| > >> <%
| > >> IF nextpagename="index.asp" THEN
| > >> className="current"
| > >> ELSE
| > >> className="someotherstylename "
| > >> END IF
| > >> %>
| >
| > >> then your html becomes
| > >> <a href="index.asp" class="<%=className%>">Home page</a>
| >
| > >> If you still are having problems post a real variable from your page and the condition you are
| > >> looking for
| > >> --
| >
| > >> _____________________________________________
| > >> SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > >> "Warning - Using the F1 Key will not break anything!" (-;
| > >> _____________________________________________
| >
| > >> message| >
| > >> | > Set up your class in the html page as a ASP variable
| > >> | > a href="index.asp" class="<%=className%>">
| > >> | > The use you server side code to change the style
| > >> | >
| > >> | > <%
| > >> | > IF ..... THEN
| > >> | > className="current"
| > >> | > ELSE
| > >> | > className="someotherstylename "
| > >> | > END IF
| > >> | > %>
| > >> | >
| > >> | > --
| > >> | >
| > >> | > _____________________________________________
| > >> | > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > >> | > "Warning - Using the F1 Key will not break anything!" (-;
| > >> | > _____________________________________________
| > >> | >
| > >> message| > >> | >
| > >> | > |I have set up a "current" state with CSS for navigational links of a
| > >> | > | website.
| > >> | > |
| > >> | > | #nav a:link.current, #nav a:visited.current {background-
| > >> | > | color:#800000;color:white;}
| > >> | > | #nav a:hover.current {background-color:#800000; color:white;
| > >> | > | cursor:default}
| > >> | > |
| > >> | > | I am using asp to inlucde headers and footers with navigation. I want
| > >> | > | to interface with CSS to show a current state for a current page. I
| > >> | > | can do this with html ie.<a href="index.asp" class="current">Home</a>
| > >> | > | but I have to use a static navigational bar which stays with the
| > >> | > | page. I am not sure how to set this up with asp?
| > >> | > |
| > >> | > | thanks
| > >> | > |
| > >> |
| > >> | Ok, I understand the logic, but I was wondering if I could set up
| > >> | somthing so that when asp reads a variable on a certain page it
| > >> | triggers the current state of the navigation. In other words is there
| > >> | a simpler way than an if then statement?
| > >> |
| > >> | If the answer is no then I am having trouble with the exact wording
| > >> | of the if then statement.
| > >> |
| > >> | thanks
| > >> |
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top