• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 559
  • Last Modified:

how to add a style to items within a CheckBoxList?

I have a CheckBoxList to which I wish to add a specific style from the css page to format the text size.
How do I achieve this?

I hjave tried adding the attribute 'CssStyle="txtSmall"' to the tag such as <asp:CheckBoxList CssStyle="txtSize" id="lbCostCenter" Runat="server" AutoPostBack="True" RepeatColumns="2" RepeatDirection="Horizontal"  width=100% />/>
But this does not work. It renders the page as <table id="lbCostCenter" class="txtSmall" border="0" style="width:100%;"> but the text for each CheckBox is the wrong size ie the css style is not applied.
If I try adding code to the cs page such as :
lbCostCenter.Attributes["CssClass"] = "txtSmall";
or
lbCostCenter.CssClass = "txtSmall";
but the result is exactly the same as the first attempt.

How do I force each <input ... />to read <input ... CssClass="txtSmall" />
0
spaceplanner
Asked:
spaceplanner
  • 5
  • 3
1 Solution
 
Roopesh_7Commented:
where u specify the style sheet? i mean the path..... first try copy this style class txtSize in your aspx page... then save close the application and restart it... check it is working or not
0
 
spaceplannerAuthor Commented:
Hi Roopesh,
I tried what you suggested but to no avail.
I do have the style defined in many other places in the app which all work fine. It is just this CheckBoxList that does not work
0
 
Roopesh_7Commented:
hiii frd check box list is rendered in different format in out put thats y its not taken....so go through this link this defenitly help you

http://www.code-magazine.com/article.aspx?quickid=0503041&page=1

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Roopesh_7Commented:
hey give like this


asp:ListItem Value="<span
 class='txtSmall'>Maintenance Tasks</span>" />
<asp:ListItem Value="<span
 class='txtSmall'>Financial Tasks</span>" />
<asp:ListItem Value="<span
 class='txtSmall'>Corporate Tasks</span>" />
0
 
spaceplannerAuthor Commented:
Roopesh,
The article is very interesting but it doesn't seem to help.
As you can see from below I am able to insert the 'CssClass=txtSmall' into a ,span. but it has no effect.

Code:
alCostCenter.Add(new AddValue("<span CssClass=txtSmall >" + dsCostCenter.Tables[0].Rows[i][0].ToString()+ " - " + dsCostCenter.Tables[0].Rows[i][1].ToString() + "</span>",dsCostCenter.Tables[0].Rows[i][0].ToString()));                                                

Page source:                        
td><input id="lbCostCenter_3" type="checkbox" name="lbCostCenter:3" onclick="__doPostBack('lbCostCenter$3','')" language="javascript" /><label for="lbCostCenter_3"><span CssClass='txtSmall' >1234 - IT Support</span></label></td>
0
 
Roopesh_7Commented:
use html control inted off aspx control
0
 
Roopesh_7Commented:
0
 
spaceplannerAuthor Commented:
what a bloody mess :P

thanks for all your help Roopesh.
My text will remain large for nwo ;)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now