ASP & CSS: highlight selected menu item

When creating menus for a web site, it is a good practise to use an inclusion, so that we write the menu only once. When the menu is included on every page, we might need to highlight the selected option in the menu itself.
For example, we can have a menu like:
  • Home Page
  • Option 1
  • Option 2
  • Option 3
When the user selects "Option 2" and load the related page, the menu should look like:
  • Home Page
  • Option 1
  • Option 2
  • Option 3
How can we do it? It's quite easy: we will use some ASP and CSS.


The menu
The menu is very simple in our example, but you will be able to apply the following concepts to any menu. Just for the sake of completeness we will consider the following structure:
The above HTML code should be in your document which will be included on every page.

The ASP part
Now we need to know which is the name of the viewed page. To do so, we are going to use a simple ASP function. Add the following snippet in your menu page (just before or after the
    list):

    <%
    Dim fileName
    fileName =(getFileName)
    %>
    As you can see, the "fileName" variable will be the name of the viewed page. We are going to use that variable in order to apply a specific CSS rule to the menu options.

    Let's get back to the menu...

    We need to change the