<asp:ListBox ID="YearListBox" runat="server" Rows="11" SelectionMode="Multiple" AutoPostBack="True"></asp:ListBox>
我怎樣才能設置所選項目的背景爲藍色。 我已經嘗試了以下解決方案,但無法在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");
}
我們可以看到所選擇的項目的背景顏色在該圖像上[1]是灰色的,但項的背景屬性是這樣的圖像[2]上藍色。
看來,瀏覽器的默認樣式覆蓋了我的背景屬性。
我想回發後,所選項目的背景顏色設置爲藍色。 – 2014-09-19 12:08:23