Change forecolor for individual listitems in CheckBoxList

Discussion in 'ASP .Net' started by Eric Robishaw, Dec 24, 2003.

  1. I'm adding items to a CheckBoxList Control, and need the text in each
    checkbox list item to be a specific color. Here's what I'm trying:

    ListItem li = new ListItem(GroupName, GroupID);
    li.Attributes.Add("ForeColor", GroupColor);
    GroupList.Items.Add (li);

    When viewing the produced HTML... there is no ForeColor attribute
    being added. My guess is because each list item is really comprised
    of two items: 1) CheckBox and 2) A label associated with it, and the
    Attributes.Add is trying to add the forecolor atribute to the
    CheckBox... not the label.

    How can I get the text itself to a specified color?

    I'd really like to use the CheckBoxList Control, if possible.

    Do you think I need to derive a control from it, and override one of
    the render methods?

    Eric
    Eric Robishaw, Dec 24, 2003
    #1
    1. Advertising

  2. Hi Eric,

    You've hit a well known bug[1]

    [1]
    http://groups.google.com/groups?q=b...TF-8&selm=u4Yvw5wzBHA.2520@tkmsftngp05&rnum=1

    --
    Victor Garcia Aprea
    Microsoft MVP | ASP.NET
    Looking for insights on ASP.NET? Read my blog:
    http://obies.com/vga/blog.aspx

    To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
    "Eric Robishaw" <> wrote in message
    news:...
    > I'm adding items to a CheckBoxList Control, and need the text in each
    > checkbox list item to be a specific color. Here's what I'm trying:
    >
    > ListItem li = new ListItem(GroupName, GroupID);
    > li.Attributes.Add("ForeColor", GroupColor);
    > GroupList.Items.Add (li);
    >
    > When viewing the produced HTML... there is no ForeColor attribute
    > being added. My guess is because each list item is really comprised
    > of two items: 1) CheckBox and 2) A label associated with it, and the
    > Attributes.Add is trying to add the forecolor atribute to the
    > CheckBox... not the label.
    >
    > How can I get the text itself to a specified color?
    >
    > I'd really like to use the CheckBoxList Control, if possible.
    >
    > Do you think I need to derive a control from it, and override one of
    > the render methods?
    >
    > Eric
    Victor Garcia Aprea [MVP], Dec 27, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Boris
    Replies:
    1
    Views:
    2,916
    binusworld
    Sep 30, 2008
  2. Replies:
    4
    Views:
    2,654
  3. Nathan Sokalski
    Replies:
    1
    Views:
    684
    bruce barker
    Mar 19, 2008
  4. Amelyan
    Replies:
    0
    Views:
    223
    Amelyan
    Apr 17, 2005
  5. Nathan Sokalski
    Replies:
    1
    Views:
    170
    bruce barker
    Mar 19, 2008
Loading...

Share This Page