ASP.NET:如何指定列表项的文本颜色?

ASP.NET:如何指定列表项的文本颜色?,asp.net,listitem,Asp.net,Listitem,如何在下面的代码中指定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> <

如何在下面的代码中指定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>

项目1
项目2
项目3
项目4
试试下面的方法

<asp:ListItem style="color:blue">Item 1</asp:ListItem>
项目1
试试下面的方法

<asp:ListItem style="color:blue">Item 1</asp:ListItem>
项目1

COLD Teld的答案看起来不错,但是如果需要指定所有项目的颜色,请执行以下操作:

<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>

.复选框列表标签
{
颜色:红色;
}
项目1
项目2
项目3
项目4

COLD Teld的答案看起来不错,但是如果需要指定所有项目的颜色,请执行以下操作:

<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>

.复选框列表标签
{
颜色:红色;
}
项目1
项目2
项目3
项目4

样式不是listitems的属性style不是listitems的属性