Rendering Newline Characters in FullDescription (ProductTemplate.Simple.cshtml)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
Anyone know how I can render the newline characters in 'Model.FullDescription'? Our Point-of-Sale uses newline characters (Windows) and I sync that data to nopCommerce. However, no newlines are rendered in the product's description.

I have tried:


string[] newlineChars = {
    "\r",
    "\n"
};

string fullDescription = Model.FullDescription;

foreach (var item in newlineChars)
{
    fullDescription.Replace(item, "<br>");
}
<div class="full-description" itemprop="description">
    @Html.Raw(fullDescription)
</div>


The above code still won't render these line breaks for me :(
7 years ago
I figured it out:


@Html.Raw(Model.FullDescription.Replace(Environment.NewLine, "<br>"))
4 years ago
To get it to work, I had to do
@Html.Raw(HttpUtility.HtmlEncode(Model.FullDescription).Replace("\n", "<br/>"))
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.