ASP.NET user control for current navigation

liunx

Guest
Hello,

I'm a complete newb with ASP.NET. What I am trying to do is create the ability to have the current link someone is on highlighted in some way so that they know they are on that page. From what I understand, I would have to create a user control to tell the page to do this.
I think my situation is a little different than normal because of how the page is set up. The links in the navbar don't lead to new pages - they are jump refs leading to different locations in one page. There is also an external javascript file being called that hides all of the sections except for the one that has been chosen from the link list.

Here's my HTML setup:


<div id="hidelinks">
<a id="hlone" href=http://www.webdeveloper.com/forum/archive/index.php/"#one">One</a>
<a id="hltwo" href=http://www.webdeveloper.com/forum/archive/index.php/"#two">Two</a>
<a id="hlthree" href=http://www.webdeveloper.com/forum/archive/index.php/"#three">Three</a>
</div>
<div id="one">
<p>a;ldjfalskdjfla;jsdfl;ajsdf</p>
</div>
<div id="two">
<p>a;sdjf;laksdjfl;aksdjff</p>
</div>
<div id="three">
<p>;alksdjf;lkadjfajr</p>


The javascript file is taken from an A List Apart article called "Let Them Eat Cake." <!-- m --><a class="postlink" href="http://www.alistapart.com/articles/eatcake/">http://www.alistapart.com/articles/eatcake/</a><!-- m -->

If anybody could just point me in a few right directions for where I can learn how to make the correct kind of user control, I would really appreciate it.
Thanks!Well... you could just do a request.servervariables(url) or just look at the query string if you are using completely data driven pages. Then from that identify which like to hylight... store the link code in variables maybe so that you can easily modify the html of the strings.1. Make hidelinks a .Net control by adding runat="server"
2. From the page load event grab the innerhtml value of hidelinks into a variable (strLinks).
3. Grab the anchor from the url and put it into a variable (strAnchor).
4. Parse (strLinks) for the value of (strAnchor) and insert an html class attribute before of after the location of the anchor with the name "active".
5. Set hidelinks.innerhtml = (strLinks).
6. Define .active in your CSS stylesheet.

Something similar could also be done in JS or some other scripting language.
 
Back
Top