p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 4.5 General Discussion (http://p2p.wrox.com/forumdisplay.php?f=711)
-   -   asp: CheckBoxList: Text not aligning with checkbox (http://p2p.wrox.com/showthread.php?t=94423)

mddevane April 23rd, 2015 10:02 PM

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

Imar April 27th, 2015 03:57 PM

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

mddevane April 27th, 2015 06:20 PM

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.....

lucygrey December 12th, 2015 03:02 AM

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!!

mmorgan30 July 2nd, 2016 12:23 AM

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.


All times are GMT -4. The time now is 10:57 AM.

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