Override Skin file in CheckBoxList item

M

mdavis

Hello,
I have a need to set the formatting of the checkboxes dynamically
added to a checkboxlist on my website. The problem is that we use a
master.skin file that overrides any classes I add to the listitems as
they are added to the checkboxlist.
I have experimented with SkinIDs in the past, but am unable to add a
SkinID to the items in the checkboxlist.

I add the items like this:
ListItem itemCategory = new ListItem();
itemCategory.Text = categoryList["CategoryName"].ToString();
itemCategory.Value = categoryList["CategoryID"].ToString();
cblCategories.Items.Add(itemCategory);

I've tried adding a class like this:
itemCategory.Attributes.Add("class", string.Concat("checkBoxOrder",
orderLevel.ToString()));

but that gets overriden by the skin file:
<asp:CheckBox runat="server" CssClass="checkBox"></asp:CheckBox>

Any help getting SkinID set on the checkboxlist items, or an
alternative way of styling would be much appreciated.

Thanks,
Max
 
D

Dave Sussman

Are you using the Theme or StylesheetTheme attribute? With Theme, the
properies of the skin will override properties declared directly on a
control, whereas StylesheetTheme will only appliy skin properties if they
aren't already set on the control. So Stylesheettheme won't overwrite.

d
 
M

mdavis

Are you using the Theme or StylesheetTheme attribute? With Theme, the
properies of the skin will override properties declared directly on a
control, whereas StylesheetTheme will only appliy skin properties if they
aren't already set on the control. So Stylesheettheme won't overwrite.

d


Hello,
I have a need to set the formatting of the checkboxes dynamically
added to a checkboxlist on my website. The problem is that we use a
master.skin file that overrides any classes I add to the listitems as
they are added to the checkboxlist.
I have experimented with SkinIDs in the past, but am unable to add a
SkinID to the items in the checkboxlist.
I add the items like this:
ListItem itemCategory = new ListItem();
itemCategory.Text = categoryList["CategoryName"].ToString();
itemCategory.Value = categoryList["CategoryID"].ToString();
cblCategories.Items.Add(itemCategory);

I've tried adding a class like this:
itemCategory.Attributes.Add("class", string.Concat("checkBoxOrder",
orderLevel.ToString()));
but that gets overriden by the skin file:
<asp:CheckBox runat="server" CssClass="checkBox"></asp:CheckBox>
Any help getting SkinID set on the checkboxlist items, or an
alternative way of styling would be much appreciated.
Thanks,
Max


I didn't realise about the StyleSheetTheme attribute - what a great
find! Looks like it's the answer.

Cheers,
Max
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top