By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,033 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Changing background-color of a ListItem

P: n/a
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


Nov 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.