Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sumesh KP 32 posts 103 karma points c-trib
    Apr 30, 2019 @ 15:53
    Sumesh KP
    0

    Replace line break for Text area in Umbraco 8

    What is alternative method for mutliline text area line brakes in umbraco 8.

    In Umbraco 7, we had the following extension method in umbraco helper.

    @Umbraco.ReplaceLineBreaksForHtml(multiLine);
    

    Thanks in advance

    Regards,

    Sumesh KP

  • Lewis Smith 199 posts 586 karma points c-trib
    Apr 30, 2019 @ 16:38
    Lewis Smith
    1

    Hi Sumesh,

    I tend to just add .Replace(Environment.NewLine, "<br />") to the output so

    Model.TextareaOutput.Replace(Environment.NewLine, "<br />")
    

    or

    Model.Value("textareaOutput").Replace(Environment.NewLine, "<br />")
    

    Lewis

  • Chris Kim 43 posts 212 karma points c-trib
    May 01, 2019 @ 04:16
    Chris Kim
    5

    I was just looking for this today as well. I found there is now an HtmlHelper:

    @Html.ReplaceLineBreaksForHtml(multiLine)
    

    Note that it returns HtmlString, not string!

    I initially copied the v7 string extension but had to revisit where I was using it, so I was searching for my extension (same name) and happened to find the HtmlHelper in /Views/Partials/Grid/Editors/Textstring.cshtml

  • Jules 205 posts 448 karma points
    Feb 08, 2021 @ 09:01
    Jules
    0

    Now it's:

    Html.ReplaceLineBreaks(text);

    ReplaceLineBreaksWithHtml is depracated

    J

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies