Solved

how to add a style to items within a CheckBoxList?

Posted on 2006-10-21
8
523 Views
Last Modified: 2012-06-27
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
Comment
Question by:spaceplanner
  • 5
  • 3
8 Comments
 
LVL 6

Expert Comment

by:Roopesh_7
ID: 17780722
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
 

Author Comment

by:spaceplanner
ID: 17780749
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
 
LVL 6

Expert Comment

by:Roopesh_7
ID: 17780772
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
 
LVL 6

Expert Comment

by:Roopesh_7
ID: 17780776
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:spaceplanner
ID: 17780864
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
 
LVL 6

Expert Comment

by:Roopesh_7
ID: 17780900
use html control inted off aspx control
0
 
LVL 6

Accepted Solution

by:
Roopesh_7 earned 500 total points
ID: 17780904
0
 

Author Comment

by:spaceplanner
ID: 17784730
what a bloody mess :P

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
asp.net mvc return json 2 57
LINQ - C# to VB convertion 12 48
ASP.NET Core index.html  LOCALHOST page cannot be found 2 25
Adware on IIS hosted asp.net website 1 20
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now