Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > CheckBoxList - how to prevent labels from wraping?

Reply
Thread Tools

CheckBoxList - how to prevent labels from wraping?

 
 
MattB
Guest
Posts: n/a
 
      11-11-2004
Hi I have a form with a CheckBoxList that gets bound at runtime. I split it
into columns if there are a lot of items, but the formatting of those
columns isn't what I was looking for. Specifically, I don't like how the
labels wrap and would like to prevent them from wrapping, but I don't see a
property that applies to this. How can I keep the labels on one line?
Thanks!

Matt


 
Reply With Quote
 
 
 
 
jongalloway
Guest
Posts: n/a
 
      11-12-2004
I looked into a property based approach and I don't think that's
supported.

I'd try wrapping the text in the ListItem in a <nobr> tag. The syntax
would be a bit different depending on how you're doing your
databinding.

You may set this to using the ListItem.Text property on the server
side, or if you're doing your databinding in the ASPX you'd use
something like
<asp:listitem><nobr><%#databinder.eval(...)%></nobr></asp:listitem>

As an example, here's the code you'd use if you weren't databinding:
<asp:CheckBoxList id="checkboxlist1"
AutoPostBack="True"
CellPadding="5"
CellSpacing="5"
RepeatDirection="Vertical"
RepeatLayout="Flow"
TextAlign="Right"
OnSelectedIndexChanged="Check_Clicked"
runat="server">

<asp:ListItem><nobr>Item 1</nobr></asp:ListItem>
<asp:ListItem><nobr>Item 2</nobr></asp:ListItem>
<asp:ListItem><nobr>Item 3</nobr></asp:ListItem>
<asp:ListItem><nobr>Item 4</nobr></asp:ListItem>
<asp:ListItem><nobr>Item 5</nobr></asp:ListItem>
<asp:ListItem><nobr>Item 6</nobr></asp:ListItem>
</asp:CheckBoxList>

- Jon
http://weblogs.asp.net/jgalloway

 
Reply With Quote
 
 
 
 
MattB
Guest
Posts: n/a
 
      11-12-2004
Awesome! the <nobr> tags worked like a charm. Thanks!

Matt

jongalloway wrote:
> I looked into a property based approach and I don't think that's
> supported.
>
> I'd try wrapping the text in the ListItem in a <nobr> tag. The syntax
> would be a bit different depending on how you're doing your
> databinding.
>
> You may set this to using the ListItem.Text property on the server
> side, or if you're doing your databinding in the ASPX you'd use
> something like
> <asp:listitem><nobr><%#databinder.eval(...)%></nobr></asp:listitem>
>
> As an example, here's the code you'd use if you weren't databinding:
> <asp:CheckBoxList id="checkboxlist1"
> AutoPostBack="True"
> CellPadding="5"
> CellSpacing="5"
> RepeatDirection="Vertical"
> RepeatLayout="Flow"
> TextAlign="Right"
> OnSelectedIndexChanged="Check_Clicked"
> runat="server">
>
> <asp:ListItem><nobr>Item 1</nobr></asp:ListItem>
> <asp:ListItem><nobr>Item 2</nobr></asp:ListItem>
> <asp:ListItem><nobr>Item 3</nobr></asp:ListItem>
> <asp:ListItem><nobr>Item 4</nobr></asp:ListItem>
> <asp:ListItem><nobr>Item 5</nobr></asp:ListItem>
> <asp:ListItem><nobr>Item 6</nobr></asp:ListItem>
> </asp:CheckBoxList>
>
> - Jon
> http://weblogs.asp.net/jgalloway



 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"pointlabel"-like function for Python: distribute text labels on a2-d scatter plot to avoid overlapping labels C Barrington-Leigh Python 1 09-12-2010 09:58 PM
Checkboxlist inside Repeater - doesn't fire click event for Checkboxlist JD ASP .Net 5 08-08-2007 11:28 AM
Labels within a CheckBoxList Mark ASP .Net 0 04-17-2007 02:27 PM
Labels within a CheckBoxList Mark ASP .Net Web Controls 0 04-16-2007 02:53 PM
Hiding CheckboxList labels student77 ASP .Net Web Controls 0 12-07-2005 07:43 PM



Advertisments