asp:label text= is too long to work with. How to work on multiple lines but not with <br>

Pierre Zarzour 0 Reputation points
2023-05-09T14:29:20.3166667+00:00

hi

on my asp:label text= fields

the text is too long

How to work on multiple lines in the html code area but not with <br> because i don't want that the text will be cut on the webpage for the client

i just want to work with long text= zone in the code area

in visual basic code we do :

"aslaskjfljksflksjafjsalfjsljkf" _

& "laskjflsjafkjsafjlsjlkfjasjfkljf" _

& "laskjflkasjlfjskjfkjsljfksalfkjasl"

thanks

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,248 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Albert Kallal 4,646 Reputation points
    2023-05-09T22:46:24.24+00:00

    Just drop in a text box with textmode=multiline

    Like this:

                <asp:TextBox ID="TextBox1" runat="server"
                    TextMode="MultiLine" 
                    Height="163px" Width="341px">
                </asp:TextBox>
    
    

    And the effect is now this: (I'll cut + paste in your question text).

    textboxwrap

    so, the word warp (word break) is automatic as above shows.

    So, a text box is a good choice. And if you don't want the user to edit the text box, you can set enabled=false.

    0 comments No comments

  2. Lan Huang-MSFT 25,471 Reputation points Microsoft Vendor
    2023-05-10T05:58:24.3466667+00:00

    Hi @Pierre Zarzour,

    You can specify the width of the label and add style="word-wrap:break-word;".

    <asp:Label ID="la" runat="server" width="100px" style="word-wrap:break-word;" ></asp:Label>

    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  3. Viorel 112K Reputation points
    2023-05-11T08:36:37.85+00:00

    Probably there is no such feature. But you can let Visual Studio to automatically wrap the lines: go to menu, TOOLS, Options, Text Editor, ASP.NET Web Forms, General, and uncheck “Enable virtual space” and check “Word wrap”. (This can be done for HTML, XAML and XML too). Then the long attribute values will be displayed by Visual Studio on multiple lines.

    0 comments No comments