I have a menu in the sidebar in a dynamic aspx page.
I want to highlight the current link based on the query string value.
<div id="verticalmenu">
<ul>
<li><a href="services.aspx?pageid=11">Medical Transcription</a></li>
<li><a href="services.aspx?pageid=12">Business Transcription</a></li>
<li><a href="services.aspx?pageid=13">Legal Transcription</a></li>
<li><a href="services.aspx?pageid=14">Insurance Transcription</a></li>
<li><a href="services.aspx?pageid=15">Data Entry & Processing</a></li>
<li><a href="services.aspx?pageid=16">Software Development</a></li>
<li> <a href="services.aspx?pageid=25">Typesetting Services</a></li>
</ul>
</div>
With jQuery, it could look something like this:
Use
window.location.search.substring(1)to take the last part of the url, and check it against thehrefattribute of your links using thesearchmethod for javascript-strings. Then add a classname for the styling purpose. I usedcurrentfor example.It might need some tweaking, but this is the way to go. However, I would strongly recommend to do this link-recognition serverside. This is a workaround I’m not too proud of.