I am working on a website and currently have a UserControl set to display the navigation
<div class="navigation">
<ul>
<li><asp:HyperLink runat="server" ID="home" Text="Home" NavigateUrl="/Default.aspx" /></li>
<li><asp:HyperLink runat="server" ID="about" Text="About Us" NavigateUrl="/AboutUs.aspx" /></li>
<li><asp:HyperLink runat="server" ID="experience" Text="Experience" NavigateUrl="/Experience.aspx" /></li>
<li><asp:HyperLink runat="server" ID="capabilities" Text="Capabilities" NavigateUrl="/Capabilities.aspx" /></li>
<li><asp:HyperLink runat="server" ID="benefits" Text="Benefits" NavigateUrl="/Benefits.aspx" /></li>
<li><asp:HyperLink runat="server" ID="contact" Text="Contact Us" NavigateUrl="/ContactUs.aspx" /></li>
</ul>
</div>
I have two pages calling the UserControl. Default.aspx and also Secondary.Master. I need to know the best approach to be able to add “CssClass=”Active” on either the parent <li> tag or the link itself.
Consider using the built-in ASP:Menu control. It has built-in capabilities to handle what you are trying to do.