Applying CSS to asp:ListItem

  • Thread starter Thread starter Merennulli
  • Start date Start date
M

Merennulli

My problem child:

<asp:dropdownlist id="ddlLimit" tabIndex="6" runat="server"
EnableViewState="False" CssClass="query">
<asp:ListItem Value="100" Selected="True">100</asp:ListItem>
<asp:ListItem Value="250">250</asp:ListItem>
<asp:ListItem Value="500">500</asp:ListItem>
</asp:dropdownlist>

My intent is to make this a gradiation of colors from blue to red,
giving 100 a natural "positive" feel and 500 a natural "negative" feel.
100 gives the top 100 results, while 500 gives the top 500, and of
course takes about 4x as long. I'm trying to encourage leaving it on
the 100 without being obtrusive.

The problem is, CssClass=, Class= and ID= don't get passed with
asp:listitem. I need to either find a CSS method of referencing them
individually, or an ASP.NET way of passing an identifier or class with
them. Any ideas?
 
In your Page_Load...


ddLimit.Items(0).attributes.add("Class","className")
ddLimit.Items(1).attributes.add("Class","className")
ddLimit.Items(2).attributes.add("Class","className")

in message
news:[email protected]...
 
Thank you, I hadn't thought of that.

Scott said:
In your Page_Load...


ddLimit.Items(0).attributes.add("Class","className")
ddLimit.Items(1).attributes.add("Class","className")
ddLimit.Items(2).attributes.add("Class","className")

in message
 
Is there a step I'm missing? I put this in the page_load, but no
attributes get added. I even tried adding other attributes, a refresh,
etc.
 
Back
Top