7

UPDATE: The below question is still valid, but I tested my page in Chrome and it works as expected. When I hit the page in IE it does not wrap. I will now start researching this difference. Let me know if you know of the IE fix for this. Thanks

I have an asp:TextBox that will not wrap. I've run across multiple articles that say I must have TextMode="MultiLine" Wrap="True", and I do, but my text still runs out of the text box.

I don't think I need to post the full page, but tell me if I do. Here's my asp:TextBox, and the CSS class acting on the <TD>. Please let me know if you see why my text is not wrapping?!

            <td class="auto-style130" >
                <asp:TextBox ID="lbl_pain1_drug" Width="400px" runat="server" Rows="4"
                    TextMode="MultiLine" Wrap="True" ReadOnly="true" BorderStyle="None"
                    BorderWidth="0" Font-Names="Tahoma" Height="55px" 
                    style="overflow:hidden" >
                </asp:TextBox>
            </td>

Here is the class="auto-style130"

.auto-style130 {
            /*sig section of script*/
            border: .1px solid #808080;
            word-wrap: break-word;
            word-break: break-all;
            height: 50px;
            width: 402px;
            vertical-align: middle;
        }
Mr Lister
  • 45,515
  • 15
  • 108
  • 150
glitzsfa
  • 353
  • 1
  • 2
  • 14
  • Textbox automatically wrap content. But if you want to display it in label it does not. Also if you write any content without space like 'aaaaaaaaaaaaaaaaaaaaaaaa....' it does not wrap content as it does not find space inside it. So please confirm which content you write within textbox. – INDIA IT TECH Mar 07 '16 at 05:12
  • @glitzsfa did you tried `word-break:break-all;word-wrap:break-word;` – Krsna Kishore Mar 07 '16 at 05:57
  • Piyush this is a TextBox, not a label, @Webruster I tried your suggestion, and it didn't work. I've edited my question above to reflect the updated code. – glitzsfa Mar 07 '16 at 14:12

2 Answers2

5

Here is the article where I found the solution, it basically says the newest IE browsers handle textbox wrapping just a little different than they used to. The solution was to add white-space: pre-wrap; my CSS. Here's what new block looked like:

.auto-style130 {
    /*drug section of script*/
    border: .1px solid #808080;
    white-space: pre-wrap;
    height: 35px;
    width: 402px;
    vertical-align: middle;
}

This made everything wrap!

Community
  • 1
  • 1
glitzsfa
  • 353
  • 1
  • 2
  • 14
0
<asp:TextBox ID="txtMonthsDays" runat="server" class="form-control input-sm m-bot15"
                                                                                            Font-Bold="true" Text='<%#Bind("MonthsDays") %>' Wrap="True" Width="50px" Rows="2"
                                                                                            TextMode="MultiLine" ForeColor="#800000"></asp:TextBox>
Code
  • 679
  • 5
  • 9