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 35 posts 108 karma points c-trib
    Apr 30, 2019 @ 15:53
    Sumesh KP
    1

    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 211 posts 620 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 48 posts 254 karma points c-trib
    May 01, 2019 @ 04:16
    Chris Kim
    6

    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 276 posts 588 karma points
    Feb 08, 2021 @ 09:01
    Jules
    3

    Now it's:

    Html.ReplaceLineBreaks(text);

    ReplaceLineBreaksWithHtml is deprecated

    J

  • Amir Khan 1289 posts 2746 karma points
    Mar 24, 2022 @ 21:37
    Amir Khan
    1

    I can't believe this isn't in the docs.

  • roger malik 17 posts 79 karma points
    Oct 24, 2022 @ 13:25
    roger malik
    0

    TRY new HtmlStringUtilities().ReplaceLineBreaks()

  • 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