title: ASP.NET MVC: How do I display multiline text?
body: <p><strong>View Model:</strong></p>
  
  <pre><code>public class Note
  {
      [DataType(DataType.MultilineText)]
      public string Text { get; set; }
  }
  </code></pre>
  
  <p>Default editor template renders a <code>&lt;textarea&gt;</code> element with the newlines preserved.</p>
  
  <p>The default display template renders the text as a single string with the newlines removed.</p>
  
  <p><strong>I tried this, but it doesn't work:</strong></p>
  
  <p>~/Views/Shared/EditorTemplates/MultilineText.cshtml</p>
  
  <pre><code>@model string
  
  @Html.Raw(Model.Replace(System.Environment.NewLine, "&lt;br /&gt;"))
  </code></pre>
  
  <p>I can do something silly like <code>@Html.Raw(Model.Replace("e", "&lt;br /&gt;"))</code> and it will work but of course I only want to replace the newline characters the <code>&lt;br /&gt;</code> element! I also tried using <code>@"\n"</code> and that didn't work either. </p>
  
  <p>Any ideas?</p>
  
  <p>Thanks!</p>