Reputation: 39364
On an ASP.NET MVC the model has the following value:
TestViewModel model = new TestViewModel {
Description = "This is a description test\r\nlorem ipsum\r\nline2\r\n\r\n-item1\r\n-item2"
}
On the view I simply have the following:
<div>@Model.Description</div>
The entire text appears in one line ... The \r\n are not making any effect.
How can I solve this?
Upvotes: 1
Views: 80
Reputation: 49095
You need to convert the newline characters to HTML's <br />
element:
<div>@Html.Raw(Model.Description.Replace(Environment.NewLine, "<br />"))</div>
Upvotes: 1