Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp:CheckBox - prevent text from wrapping below checkbox

Tags:

asp.net

I have a Checkbox with text that is fairly lengthy as shown below. One thing we don't want is for the text to wrap below the checkbox. What I have done to fix this is to put spaces. Also not that part of the text is bold as well:

     <asp:CheckBox ID="chkOption1" runat="server" /> <b><u>Option 1</u></b> - Attend in person. This is the best way to gain critical knowledge and express your thoughts and opinions.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ample time will be provided for individual discussions during breaks and at the networking reception.

Is there a way for the text not to wrap below the checkbox and still have the boldness in the text I need?

Note that I still want the text to wrap but not below the checkbox. Meaning it should wrap below the previous line's text.

like image 424
Nate Pet Avatar asked Feb 16 '14 13:02

Nate Pet


2 Answers

From the moment you have the text outside of your check box you can warp it with a span and nowrap style as:

<span style="white-space: nowrap;">
<asp:CheckBox ID="chkOption1" runat="server" /> <b><u>Option 1</u></b> - Att ........
</span>

if you place your text inside the text of your check box, you can use the style attribute as:

<asp:CheckBox runat="server" ID="chkOption1" style="white-space: nowrap;" Text="too long text" />

The render html is the same.

like image 133
Aristos Avatar answered Oct 11 '22 12:10

Aristos


This link describes a solution. In short:

  • do not use the CheckBox Text
  • rather, use an extra Label
  • set the CheckBox style float: left
  • set the Label style display: table
like image 2
dirkj Avatar answered Oct 11 '22 12:10

dirkj