Re: Highlighting current navigation link?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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 = "";
}
}

.



Relevant Pages

  • Re: Drop down boxes
    ... margin-bottom: 0"> ... font-weight: bold"> ... Yampa Valley Land Trust is a dynamic, results-oriented, ...
    (microsoft.public.frontpage.programming)
  • RE: DataGrid Conditional Formatting
    ... font-weight: bold; ... font-size: 10pt; ... background-color: black; ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • RE: DataGrid Conditional Formatting
    ... font-weight: bold; ... font-family: Verdana; ... background-color: black; ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • RE: DataGrid Conditional Formatting
    ... font-weight: bold; ... font-family: Verdana; ... background-color: black; ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • RE: First and last day of the month
    ... font-weight: bold; ... color: #cc00cc; ... background: #dbdbdb; ...
    (microsoft.public.sqlserver.programming)