0

I have a list box on my site which has a specific width. The problem is that sometimes the text is too large and is cut off of the list. What I am hoping is to insert a new line on every entry in the list box (every ) so that it automatically becomes a new line.

Is it possible?

The list Box (Notice the text being cropped)

enter image description here

Code

 <asp:ListBox ID="lstLegalEntity" runat="server" SelectionMode="Multiple" CssClass="client-bg-repeat" ForeColor="#000060" AutoPostBack="True">
    <asp:ListItem>Select One Two Three Four Five Six Seven Eight</asp:ListItem>
    <asp:ListItem>Select One Two Three Four Five Six Seven Eight</asp:ListItem>
    <asp:ListItem>Select One Two Three Four Five Six Seven Eight</asp:ListItem>
    <asp:ListItem>Select One Two Three Four Five Six Seven Eight</asp:ListItem>
</asp:ListBox>

What I am hoping is that I can put in every List Item's text into a function which inserts a "Line Break" after every 7 characters so that no entry is cut off and every long entry is shown in two lines.

Thanks.

Steve
  • 2,546
  • 8
  • 49
  • 94
  • You'll probably have to use another approach, such as a DataList or Repeater, or
      with
    • .
    – DOK Sep 30 '13 at 00:00
  • The best way to do this would be client side with CSS (as it is for display purposes). The problem is, [you can't use CSS effectively to break lines in `select` elements](http://stackoverflow.com/a/3587965/1265817). You will likely need to either shorten the values, or make a custom select box and style that as needed. – DACrosby Sep 30 '13 at 00:12

0 Answers0