Accessing href attribute for menu system?

Discussion in 'ASP General' started by Robert Mark Bram, Sep 30, 2004.

  1. 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
    :)
     
    Robert Mark Bram, Sep 30, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. CRON
    Replies:
    24
    Views:
    200,825
    Adrienne Boswell
    Jun 20, 2006
  2. Soren Vejrum
    Replies:
    4
    Views:
    624
    Lasse Reichstein Nielsen
    Jul 5, 2003
  3. saiho.yuen
    Replies:
    3
    Views:
    435
    kaeli
    Sep 14, 2004
  4. Replies:
    2
    Views:
    480
  5. Vincent van Beveren

    BASE HREF and A HREF="#" onclick="..."

    Vincent van Beveren, Jul 6, 2006, in forum: Javascript
    Replies:
    2
    Views:
    329
    Vincent van Beveren
    Jul 6, 2006
Loading...

Share This Page