For Programmers: Free Programming Magazines  


Home > Archive > ASP > September 2004 > Accessing href attribute for menu system?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Accessing href attribute for menu system?
Robert Mark Bram

2004-09-30, 3:55 pm

Hi All!

I have a menu system on my asp pages that use tables with a bunch of cells
like this:
<td class="menuHeader"><a href="../default.asp">Home</a></td>
<td class="menuEntry"><a href="../blog/default.asp">Blog!</a></td>
<td class="menuEntry"><a href="linkOMatic/default.asp">Link-O-Matic</a></td>

Now I want a system where one of the cells has a different class if that
page is being viewed. So, if default.asp is being viewed, that cell would
be:
<td class="classy"><a href="../default.asp">Home</a></td>

My question is how to do this. I have two ideas.

1)
Each page has an id..
<% var pageId=33; %>

<td class="<%=(pageId=33?"classy":"menuHeader")%>"><a
href="../default.asp">Home</a></td>

I know this one will work ok, but it is clumsy - I will have to handcode
each menu item and give each page a pageId just to implement this.

2)
This is what I was thinking of instead:
<td class="<%=(Request.ServerVariables("SCRIPT_NAME")==THIS
HREF?"classy":"menuHeader")%>"><a href="../default.asp">Home</a></td>
Is there a way to write ASP that can access the HREFF attribute of the
anchor tag in this way? If I could do this, I would not need to hand code
anything - all the changes could be made with a find-replace.

Thanks for any advice!

Rob
:)




Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com