Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 56213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:29:57+00:00 2026-05-10T17:29:57+00:00

My master page contains a list as shown here. What I’d like to do

  • 0

My master page contains a list as shown here. What I’d like to do though, is add the ‘class=active’ attribute to the list li thats currently active but I have no idea how to do this. I know that the code goes in the aspx page’s page_load event, but no idea how to access the li I need to add the attribute. Please enlighten me. Many thanks.

<div id='menu'>   <ul id='nav'>     <li class='forcePadding'><img src='css/site-style-images/menu_corner_right.jpg' /></li>                    <li id='screenshots'><a href='screenshots.aspx' title='Screenshots'>Screenshots</a></li>     <li id='future'><a href='future.aspx' title='Future'>Future</a></li>     <li id='news'><a href='news.aspx' title='News'>News</a></li>     <li id='download'><a href='download.aspx' title='Download'>Download</a></li>     <li id='home'><a href='index.aspx' title='Home'>Home</a></li>     <li class='forcePadding'><img src='css/site-style-images/menu_corner_left.jpg' /></li>   </ul> </div> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T17:29:58+00:00Added an answer on May 10, 2026 at 5:29 pm

    In order to access these controls from the server-side, you need to make them runat=’server’

    <ul id='nav' runat='server'>   <li class='forcePadding'><img src='css/site-style-images/menu_corner_right.jpg' /></li>                  <li id='screenshots'><a href='screenshots.aspx' title='Screenshots'>Screenshots</a></li>   <li id='future'><a href='future.aspx' title='Future'>Future</a></li>   <li id='news'><a href='news.aspx' title='News'>News</a></li>   <li id='download'><a href='download.aspx' title='Download'>Download</a></li>   <li id='home'><a href='index.aspx' title='Home'>Home</a></li>   <li class='forcePadding'><img src='css/site-style-images/menu_corner_left.jpg' /></li> </ul> 

    in the code-behind:

    foreach(Control ctrl in nav.controls) {    if(!ctrl is HtmlAnchor)    {       string url = ((HtmlAnchor)ctrl).Href;       if(url == GetCurrentPage())  // <-- you'd need to write that          ctrl.Parent.Attributes.Add('class', 'active');    } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a Master page, I have this.... <ul id=productList> <li id=product_a class=active> <a href=>Product
I have a master page called SampleMaster.master and this page contains a Repeater control
I have a one master Page. I want to add 3 Menu items to
I have a unordered list in my master page.... <ul id=mainMenu runat=server> <li id=mainHome
Master page contains 2 columns: Left column is JQuery UI accordion whose width can
I have a master page which contains everything that inherits it within a form.
I am getting this error: List does not exist The page you selected contains
I've a master page that contains a dropdown menu. on the inner page I've
I have a site.master page in an asp application which contains a div menu
ASP .NET MVC2 application. Site.Master file contains number of ul list link names, url

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.