Applying CSS to asp:ListItem

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?
 
S

Scott M.

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]...
 
M

Merennulli

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
 
M

Merennulli

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top