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 9209843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:56:27+00:00 2026-06-18T00:56:27+00:00

Hi all I would like to apply css for <li> tag which is in

  • 0

Hi all I would like to apply css for <li> tag which is in master page dynamically from code behind this is my design

<div id="primary_nav">
    <ul>
       <li class="left active" id="nav_discussion" runat="server">
           <a title="Go to Forums" href="">
               Forums
           </a>
       </li>
       <li class="left" id="nav_members" runat="server">
           <a title="Go to Member List" href="Members.aspx">
               Members
           </a>
       </li>
    </ul>
 </div>

enter image description here
In my content page I accessed <li> as follows

Control li = Page.Master.FindControl("nav_members");

But I am unable to apply the required css here can some one help me

  • 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. Editorial Team
    Editorial Team
    2026-06-18T00:56:28+00:00Added an answer on June 18, 2026 at 12:56 am

    In this case, your Control is of type HtmlGenericControl which does not contain a property for CssClass.

    You will need to cast your control to type HtmlGenericControl. e.g.

    System.Web.UI.HtmlControls.HtmlGenericControl li = (System.Web.UI.HtmlControls.HtmlGenericControl) this.Page.Master.FindControl("nav_members");
    

    This will then give you two choices to apply the style to the element. You can either use the Style property or the Attributes property.

    The Style property will allow you to add inline styling to the element e.g.:

    li.Style.Add("Color", "Black");
    

    This will render the element with:

    style="color:red;"
    

    Your other option is to use the Attributes property which will allow you to add the class.

    li.Attributes.Add("class", "nameofyourclass");
    

    Read more about the HtmlGenericControl

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to apply a CSS stylesheet to all page views in a
All I would like to do is create a viewport which maps a 3D
I would like to collect all the <script> ....</script> code section present in the
I would like to apply a different style to all anchors containing a specific
Currently, all my images look like this: HTML <img class=photo src=foo.png /> CSS .photo
I have some text rotated 270 degrees, which I would like to apply the
Please see working code here: http://jsfiddle.net/hrnDG/6/ I would like to modify this code so
I would like to select all elements which are outside of my container div
I have some CSS theming which I would like to do to the head
I would like to apply CSS to a checkbox in the jQuery Datatables plugin

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.