Re: Highlighting current navigation link?
- From: chris@xxxxxxxxxxxxxxxx
- Date: 28 Jul 2005 03:45:41 -0700
Right -- I've solved my own problem.
..ASCX:
<div id="menu" class="menu" runat="server">
<a href="/travel_insurance_quote.aspx" runat="server">get a quote</a>
<a href="/summary_of_cover.aspx" runat="server">summary of cover</a>
<a href="/rate_compare.aspx" runat="server">rate comparisons</a>
<a href="/claims.aspx" runat="server">claims</a>
<a href="/policy_wording.aspx" runat="server">policy wording</a>
<a href="/who_are_we.aspx" runat="server">who are we?</a>
<a href="/contact_us.aspx" runat="server">contact us</a>
<a href="/faq.aspx" runat="server">faq</a>
<a href="/become_affiliate.aspx" runat="server">become an
affiliate</a>
</div>
..CSS:
..menu a.active { font-weight: bold }
..CS (the following is inserted in Page_Load):
foreach( System.Web.UI.Control control in menu.Controls )
{
HtmlAnchor link = control as HtmlAnchor;
if ( link == null ) continue;
if( Request.Path.IndexOf( link.HRef ) != -1 )
{
// Link is active (the href is a substring of the current address)
link.Attributes.Add( "class", "active" );
link.HRef = "";
}
}
.
- References:
- Highlighting current navigation link?
- From: chris
- Highlighting current navigation link?
- Prev by Date: Re: Error accessing Temporary ASP.NET Files
- Next by Date: RE: Setting controls' name
- Previous by thread: Highlighting current navigation link?
- Next by thread: Setting controls' name
- Index(es):
Relevant Pages
|