Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > CheckBoxList items attributes : apply CssStyle

Reply
Thread Tools

CheckBoxList items attributes : apply CssStyle

 
 
Jerome
Guest
Posts: n/a
 
      07-15-2003
Hello,

I populate dynamically a CheckBoxList then try to apply a specific
font/size/color to the items of that CheckBoxList.
My code compiles but it seems I cannot reach the items...
(following pieces of code in C#)

************************************************** ******

//I populate my CheckBoxList called cblSpec
cblSpec.DataSource = specColl;
cblSpec.DataValueField = "Id";
cblSpec.DataTextField = "Libelle";
cblSpec.DataBind();

//then I try to apply a specific font, color, whatever style
//to each item in that CheckBoxList
foreach (ListItem item in cblSpec.Items)
{
item.Attributes.CssStyle.Add("font","10pt verdana");
item.Attributes.CssStyle.Add("color","red");
}

**************************************************
I cannot find any verdana keyword in the html source of the page once
I've launched it. The style (font/color) simply disappears into thin
air and is never rendered.

All I was able to do is apply a style to the CheckBoxList itself but
only the color would be applied downward to the items, not the font

************************************************** **

System.Web.UI.AttributeCollection myAttrib = cblSpec.Attributes;
myAttrib.CssStyle.Add("color","blue"); //works on the items
myAttrib.CssStyle.Add("font-weight","bold"); //works on the items
myAttrib.CssStyle.Add("font","10pt times"); //does NOT reach the items


************************************************** **

I cant find any exemple anywhere on the web or MS help.
Seems like it's impossible but I might be wrong so if anyone ever
managed to do such a thing, please copy/paste some code.
thx,

Jerome - http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
Victor Garcia Aprea [MVP]
Guest
Posts: n/a
 
      07-16-2003
Hi Jerome,

You've hit a well-known bug. Do a quick search on http://groups.google.com
to find tons of post about it. I've posted about it more than a year ago
along with some code to work-around it.

--
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
and not by private mail.

"Jerome" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Hello,
>
> I populate dynamically a CheckBoxList then try to apply a specific
> font/size/color to the items of that CheckBoxList.
> My code compiles but it seems I cannot reach the items...
> (following pieces of code in C#)
>
> ************************************************** ******
>
> //I populate my CheckBoxList called cblSpec
> cblSpec.DataSource = specColl;
> cblSpec.DataValueField = "Id";
> cblSpec.DataTextField = "Libelle";
> cblSpec.DataBind();
>
> //then I try to apply a specific font, color, whatever style
> //to each item in that CheckBoxList
> foreach (ListItem item in cblSpec.Items)
> {
> item.Attributes.CssStyle.Add("font","10pt verdana");
> item.Attributes.CssStyle.Add("color","red");
> }
>
> **************************************************
> I cannot find any verdana keyword in the html source of the page once
> I've launched it. The style (font/color) simply disappears into thin
> air and is never rendered.
>
> All I was able to do is apply a style to the CheckBoxList itself but
> only the color would be applied downward to the items, not the font
>
> ************************************************** **
>
> System.Web.UI.AttributeCollection myAttrib = cblSpec.Attributes;
> myAttrib.CssStyle.Add("color","blue"); //works on the items
> myAttrib.CssStyle.Add("font-weight","bold"); //works on the items
> myAttrib.CssStyle.Add("font","10pt times"); //does NOT reach the items
>
>
> ************************************************** **
>
> I cant find any exemple anywhere on the web or MS help.
> Seems like it's impossible but I might be wrong so if anyone ever
> managed to do such a thing, please copy/paste some code.
> thx,
>
> Jerome - (E-Mail Removed)



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checkboxlist inside Repeater - doesn't fire click event for Checkboxlist JD ASP .Net 5 08-08-2007 11:28 AM
Looping through CheckBoxList items doesn't pick up selected ones when items were disabled Bart Van Hemelen ASP .Net 2 09-04-2006 08:35 AM
Programmatically changing CssStyle on Panels depending on DB values mattsthompson@gmail.com ASP .Net Web Controls 1 06-22-2005 04:00 PM
How to get Selected item in a Databinded CheckBoxList when CheckBoxlist is in a DataList? Patrick.O.Ige ASP .Net 5 06-19-2005 06:11 AM
[XSLT] could not apply "apply-templates" Stefan Siegl XML 1 07-18-2003 09:43 AM



Advertisments