user763554
user763554

Reputation: 2041

ASP.NET: How to specify text color of a ListItem?

How do I specify the text color of a ListItem in the following code? Thanks.

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

Upvotes: 0

Views: 6605

Answers (2)

COLD TOLD
COLD TOLD

Reputation: 13599

try something like

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

Upvotes: 3

Denys Wessels
Denys Wessels

Reputation: 17049

COLD TOLD's answer looks good, however if you need to specify the colour for all the items do this instead:

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

Upvotes: 1

Related Questions