2012-12-20 22 views
0

如何在下面的代碼中指定ListItem的文本顏色?謝謝。ASP.NET:如何指定ListItem的文本顏色?

<asp:CheckBoxList id="check1" AutoPostBack="True" 
TextAlign="Right" OnSelectedIndexChanged="Check" 
runat="server"> 

<asp:ListItem>Item 1</asp:ListItem> 
<asp:ListItem>Item 2</asp:ListItem> 
<asp:ListItem>Item 3</asp:ListItem> 
<asp:ListItem>Item 4</asp:ListItem> 

</asp:CheckBoxList> 

回答

3

嘗試像

<asp:ListItem style="color:blue">Item 1</asp:ListItem> 
+0

風格不列表項的屬性 –

1

COLD TOLD的答案看起來不錯,但是如果你需要指定顏色所有的項目做到這一點,而不是:

<head runat="server"> 
    <title></title> 
    <style type="text/css"> 
     .checkboxList label 
     { 
      color:Red; 
     } 
    </style> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <div> 
     <asp:CheckBoxList CssClass="checkboxList" ID="check1" AutoPostBack="True" TextAlign="Right" 
      runat="server"> 
      <asp:ListItem>Item 1</asp:ListItem> 
      <asp:ListItem>Item 2</asp:ListItem> 
      <asp:ListItem>Item 3</asp:ListItem> 
      <asp:ListItem>Item 4</asp:ListItem> 
     </asp:CheckBoxList> 
    </div> 
    </form> 
</body>