Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4.5 > ASP.NET 4.5 General Discussion
ASP.NET 4.5 General Discussion For ASP.NET 4.5 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4.5 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 23rd, 2015, 10:02 PM
Registered User
Join Date: Aug 2014
Posts: 8
Thanks: 2
Thanked 0 Times in 0 Posts
Default asp: CheckBoxList: Text not aligning with checkbox

In my .aspx file, I have the following code:

                 <asp:CheckBoxList ID="CheckBoxClassRegion" runat="server" DataSourceID="SqlDataSourceCR" 
                                  DataTextField="HighSchoolName" DataValueField="HighSchoolName"  
                                  OnSelectedIndexChanged="CheckBoxClassRegion_SelectedIndexChanged" RepeatLayout="Flow" TextAlign="Right">
I get a result that looks something like this:





I am looking to have the resulting text aligned to the right of the checkbox, but regardless of my TextAlign value, the checkbox and text are not on the same horizontal alignment. Any suggestions as to how to get these items on the same line?

Thank You
Old April 27th, 2015, 03:57 PM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Can it be something in your CSS that sets the display property to block for either your input elements or the label? By default, the checkbox and label are on the same row, so your CSS must be forcing the linebreak somehow.


Imar Spaanjaars
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
mddevane (April 27th, 2015)
Old April 27th, 2015, 06:20 PM
Registered User
Join Date: Aug 2014
Posts: 8
Thanks: 2
Thanked 0 Times in 0 Posts
Default asp: CheckBoxList: Text not aligning with checkbox

I had to go back to the SiteMaster file and comment out references to the CSS file, but it works! I was planning on using this in another site with a different site master anyway!

Thanks again.....
Old December 12th, 2015, 03:02 AM
Registered User
Join Date: Dec 2015
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Hi

Use the following code to align text with checkbox in Asp.net

<asp:CheckBoxList ID="CheckBoxList_Genres" runat="server" RepeatColumns="3">
<asp:ListItem Selected="True">Action</asp:ListItem>
<asp:ListItem Selected="True">Comedy</asp:ListItem>
<asp:ListItem Selected="True">Classics</asp:ListItem>
<asp:ListItem Selected="True">Documentary</asp:ListItem>

Old July 2nd, 2016, 12:23 AM
Friend of Wrox
Join Date: Feb 2014
Posts: 136
Thanks: 1
Thanked 10 Times in 10 Posts

typically when things get squeezed together (wrapped) it because the parent container can not support the width. you either need to increase the widths, make paddings and margins smaller, change the font, font size, or even shorten your text down.

Last edited by mmorgan30; July 2nd, 2016 at 12:25 AM..

Similar Threads
Thread Thread Starter Forum Replies Last Post
asp: CheckBoxList: Text not aligning with checkbox mddevane BOOK: Beginning ASP.NET 4.5.1 : in C# and VB 2 April 23rd, 2015 09:59 PM
Beginning ASP 3.0: changing text field to checkbox AlanM Classic ASP Basics 0 July 1st, 2007 03:36 AM
aligning text in ul to top of image interrupt CSS Cascading Style Sheets 0 March 2nd, 2006 09:50 AM
Aligning Text in a Listview Control? xgbnow VB How-To 1 September 30th, 2004 06:37 AM
Aligning Text of a textbox mahulda General .NET 0 July 27th, 2004 12:16 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.