Solved

how to add a style to items within a CheckBoxList?

Posted on 2006-10-21
8
539 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

821 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