Home
Manage Your Code
Snippet: Making Label show multiline text (C#)
Title: Making Label show multiline text Language: C#
Description: When data is collected via a textbox and line breaks are provided in the input, this is a way to show those breaks in a label. Views: 274
Author: Developer Brainspark Date Added: 10/11/2007
Copy Code  
1 public string WrappableText(string source)
2    {
3        string nwln = Environment.NewLine;
4        return "<p>" +
5        source.Replace(nwln + nwln, "</p><p>")
6        .Replace(nwln, "<br />") + "</p>";
7    } 
Usage
 public string WrappableText(string source)
    {
        string nwln = Environment.NewLine;
        return "

" + source.Replace(nwln + nwln, "

") .Replace(nwln, "
") + "

"; }