views:

949

answers:

1

hai guys,

I dont know how to apply css for a HTML Generic control like <UL> and <LI> given runat="server" in asp.net.... I am finding the <li> in a master page from a content page... Once i found that control i want to apply css...

<ul id="mainMenu" runat="server" style="width:350px;"> 
<li id="mainHome" runat="server"><a title="Home" href="#" class="home">Home</a>
 </li> 
<li id="mainManage" runat="server"><a title="Manage" href="#" 
class="manage">Manage</a></li>
<li id="mainEnquiry" runat="server"><a title="Enquiry" href="#" 
class="enquiry">Enquiry</a></li> 
<li id="mainReport" runat="server"><a title="Report" href="#" 
  class="report">Reports</a></li>

+1  A: 

Plz try this...

ull.Style.Add("background-color", "Red");

OR I have tested this, will defintly work, Plz check

ull.Attributes.Add("class", "yourClass");

Edit: to test this solution i have provided you:

  1. make new blank master page and put

  2. then make add new page and use above master page.

  3. make findcontrol ul and put css as I have mentioned in the answer.

  4. then run your page, and view source of your html page and you will find what you are looking for. like

Muhammad Akhtar
Hai Akthar, I use find control to find a list named "home" like thisControl list = this.Master.FindControl("mainMenu").FindControl("mainHome");now how to aplly css for the control list....
Pandiya Chendur
Akthar i want to apply for a control in a master page from a content page.....
Pandiya Chendur