Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4.5 > ASP.NET 4.5 General Discussion
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 23rd, 2015, 11:02 PM
Registered User
Points: 32, Level: 1
Points: 32, Level: 1 Points: 32, Level: 1 Points: 32, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2014
Location: Savannah, GA
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:

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

[]
ItemOne

[]
ItemTwo

[]
ItemThree

----------------------

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
Reply With Quote
  #2 (permalink)  
Old April 27th, 2015, 04:57 PM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,955
Thanks: 79
Thanked 1,556 Times in 1,533 Posts
Default

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.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
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!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
mddevane (April 27th, 2015)
  #3 (permalink)  
Old April 27th, 2015, 07:20 PM
Registered User
Points: 32, Level: 1
Points: 32, Level: 1 Points: 32, Level: 1 Points: 32, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2014
Location: Savannah, GA
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.....
Reply With Quote
  #4 (permalink)  
Old December 12th, 2015, 03:02 AM
Registered User
Points: 15, Level: 1
Points: 15, Level: 1 Points: 15, Level: 1 Points: 15, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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>


Thanks!!
Reply With Quote
  #5 (permalink)  
Old July 2nd, 2016, 01:23 AM
Friend of Wrox
Points: 528, Level: 8
Points: 528, Level: 8 Points: 528, Level: 8 Points: 528, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2014
Posts: 136
Thanks: 1
Thanked 10 Times in 10 Posts
Default

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 01:25 AM.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 10:59 PM
Beginning ASP 3.0: changing text field to checkbox AlanM Classic ASP Basics 0 July 1st, 2007 04: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 07:37 AM
Aligning Text of a textbox mahulda General .NET 0 July 27th, 2004 01:16 AM



All times are GMT -4. The time now is 10:38 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.