The ListBox
<asp:ListBox ID="YearListBox" runat="server" Rows="11" SelectionMode="Multiple" AutoPostBack="True"></asp:ListBox>
How can I set the selected items' background to blue. I have tried the following solution, but not working correctly in chrome.
int[] YearIndexes = YearListBox.GetSelectedIndices();
for (int i = 0; i < YearIndexes.Length; i++)
{
//do something...
YearListBox.Items[YearIndexes[i]].Attributes.Add("style", "background-color:blue");
}
We can see the selected items' background color on this image [1] is gray, but the items' background property is blue on this image [2].
It seems that browser's default style is override my background property .