I have a simple unordered list with links in it.
<body>
<div id="topMenu">
<ul>
<li><a class="selected" href="../Default.aspx">Start</a></li>
<li><a href="../Category/ShowAll.aspx">Categories</a></li>
<li><a href="../Elements/ShowAll.aspx">Elements</a></li>
<li><a href="../Articles/ShowAll.aspx">Articles</a></li>
</ul>
</div>
<asp:ContentPlaceHolder ID="MainContentPlaceholder" runat="server">
</asp:ContentPlaceHolder>
</body>
I want to change the class of the link i click to the “selected” class, which is the easiest way to do this. I thought about making it into linkbuttons and saving the info in the session, but that seems overkill, there has to be an easier approach?
Well, you can just put the
<a>to berunat="server"and then access them from codebehind:You can have this in your master page with the menu, and you can have your child pages send the id of the hyperlink they need selected, something like
In your master (the linkWrapper can be your
<ul>asrunat server):In your child: