|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
Asp dynamically created pages - need to set menu items as 'active'
Hi,
I have a series of dynamically created HTML pages. This query relates to the menu - my issue is that I need to set the 'a:active' state for the relevant menu items to show the current page, but as the pages are dynamicallly created, not static I'm not sure how I can go about doing this. The menu is defined in a menu.ascx file, and then called into each of the HTML pages using asp. Just to clarify - Ordinarily, on static pages you would have something like: <div id="menu" class="menu"> <menu id="active" href="someurl">HOME</a> <menu id="inactive" href="someurl">ABOUT US</a> </div> or <div class="menu"> <ul> <li id="active" href="someurl">HOME</li> <li id="inactive" href="someurl">ABOUT US</li> </ul> </div> And then the home page (for example) would show a different icon to the rest of the menu -as defined by CSS (.menu active/inactive). Each page would have a different 'active' menu item - however as these are not static pages - I am unable to do that. Using a:visited would make every menu item show the 'current' icon -and once it had been viewed - it would never return to the original state I was thinking that I would be able to use some sort of script in the head to facilitate this need - something like: if pageID = 459 then menu id 'home' = active (or something akin to that) -and then go through the seperate menu items/pages. I think some sort of script would be the only viable solution - although I could be wrong as I'm unfamiliar with Asp - any help please? Many many thaks in advance! Mike |
|
#2
|
|||
|
|||
|
You could check the URL of the page with VBScript using something like so:
Code:
Thispage = Request.ServerVariables("script_name")
pageName = Split(thispage, "/")
Then perform the check inline on each link like so: Code:
<a <% If pageName(1) = "thispage.asp" Then %> class="active" <% End If %>href="thisPage.asp">This Page</a> Simple but it works... Tim |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Asp dynamically created pages - need to set menu items as 'active' |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|