Search code examples
c#.netasp.net.net-3.5

Adding new line to label


I get the data from the database and display that data on the label. I have to apply new line on the text of the label for every 35 charecters. Because after 35 charecters the text overflows.

Can you please let me know how to do this.


Solution

  • Just change the style of the label so it will wrap the text:

    style=" width:50px; overflow-y:auto;overflow-x:auto; word-break:break-all;"
    

    Better yet, put this in your CSS file rather than directly on the control.

    Another option, if you don't like this, is to use a textbox and style it as a label, as described in this post.