Get a new line in Label HTML

I save text from Textarea. And the text is also saved with a new line, as well:

   text= "Line1\nLine2"

I get data from the database in the above format. But how can I use a new line to show it on the screen<label>@text</label>

Here is the JSFiddle link for my question: http://jsfiddle.net/rjha999/J8kRw/

I get server side data in a form like:

 var model = db.GetDossierHeadeRemarks.Select(remarks => new NotesViewModel {
                UserName="RJ",
                Remark=remarks.Remark.Replace("\n","<br/>")
                }).ToList();

But on my browse page, I show this data form as:

<label class="RemarkContent">@item.Remark</label>

But the result that I get looks like:

enter image description here

+3
source share
2 answers

Use the helper method @Html.Raw().

<label class="RemarkContent">@Html.Raw(item.Remark)</label>
+2
source

To display text with line breaks in a text field: you can use &#10;

- html: replace ( ), \n <br />

0

All Articles