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
| > >> |
|
|