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>

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
In this case, your
Controlis of typeHtmlGenericControlwhich does not contain a property forCssClass.You will need to cast your control to type HtmlGenericControl. e.g.
This will then give you two choices to apply the style to the element. You can either use the
Styleproperty or theAttributesproperty.The
Styleproperty will allow you to add inline styling to the element e.g.:This will render the element with:
Your other option is to use the
Attributesproperty which will allow you to add theclass.Read more about the HtmlGenericControl