Changing background-color of a ListItem

T

Tom

Hi

I have a ListBox control of my asp.net web page. I want to set the value of
the style property of the ListItem to a specific background color.

I have tried this but no success:

//li is the ListItem object

li.Attributes.CssStyle.Add("BACKGROUND-COLOR:","blue");

and

li.Attributes.CssStyle.Add("background-color:","blue");



In the pure HTML control I can do this without problem. Each option shows a
different color:

<SELECT size="10">
<OPTION style="BACKGROUND-COLOR: blue">hello</OPTION>
<OPTION style="BACKGROUND-COLOR: yellow">there</OPTION>
<OPTION style="BACKGROUND-COLOR: green">1</OPTION>
<OPTION style="BACKGROUND-COLOR: red">2</OPTION>
</SELECT>

Any help is appreciated.

Thanks
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top