Archive for April, 2008

How to highlight menu item with ASP

This is a non-ASP.NET tip.

You have to write some code to difference the active item from the rest… The CSS:

ul, li {
/* … some style you want */
color:#000066
}
.active { color:#0000CC }

And the page code…

<%
pag = request.servervariables(”URL”)
strPosA = InStr(1, pag, “Default”, 1)
strPosB = InStr(1, pag, “Contact”, 1)
strPosC = InStr(1, pag, “Software”, 1)
indexOn = “”
contactOn = “”
softOn = “”

If strPosA <> 0 Then
indexOn = ” class=”"active”"”
ElseIf strPosB <> 0 Then
contactOn = ” class=”"active”"”
ElseIf strPosC <> 0 Then
softOn = ” class=”"active”"”
End If
%>

<div id=”nav”>
<ul>
<li><a href=”./”<% Response.Write(indexOn) %>><span>Home</span></a></li>
<li><a href=”./software.asp”<% Response.Write(softOn) %>><span>Our App</span></a></li>
<li><a href=”./contact.asp”<% Response.Write(contactOn) %>><span>Contact us</span></a></li>
</ul>
</div>

So with this, when you are on the main page, you will see the Home button / link with a blue color, different than the rest (to make sure you are in that page). And if you change to Software Page the blue item will be Our App…

The reference for PHP highlight is:
http://www.crucialwebhost.com/blog/you-are-here-using-php-to-highlight-navigation/