Copied to clipboard

Flag this post as spam?

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


  • Roberto Bianchi 137 posts 445 karma points c-trib
    Aug 26, 2015 @ 10:22
    Roberto Bianchi
    0

    Problem with replace line breaks

    I have read the documentation where is explained how to replace line breaks with html tag.

    Inside a jquery script I use this code:

    @{
        foreach(var itemfinale in CurrentPage.Children)
        {
            if(itemfinale.HasValue("descrizioneCompleta"))
            {                       
                <text>
                   @{
                    var multiLine = @itemfinale.descrizioneCompleta;
                   }
    
                   $(".sfondo-nero-opaco").append("@Umbraco.ReplaceLineBreaksForHtml(multiLine)");
                </text>
            }
        }
    }
    

    But I received this error:

    The best overloaded method match for 'Umbraco.Web.UmbracoHelper.ReplaceLineBreaksForHtml(string)' has some invalid arguments

    On line:

    @Umbraco.ReplaceLineBreaksForHtml(multiLine);
    

    Where am I wrong ?

  • Jesper Lysgaard 16 posts 76 karma points
    Aug 26, 2015 @ 10:43
    Jesper Lysgaard
    0

    Hi,

    Are you sure that @itemfinale.descrizioneCompleta returns a string?

    You could try to print out a typeof or gettype at runtime on it..

    If it is an object or something the error makes sense.

    /Jesper

  • Roberto Bianchi 137 posts 445 karma points c-trib
    Aug 26, 2015 @ 10:47
    Roberto Bianchi
    0

    Hi Jesper :)

    Yes, @itemfinale.descrizioneCompleta returns a string on two line. I saw it from the console...

  • Jesper Lysgaard 16 posts 76 karma points
    Aug 26, 2015 @ 11:19
    Jesper Lysgaard
    0

    Ok.

    You could try to typecast to be sure:

    multiLine.ToString()

    or @Umbraco.ReplaceLineBreaksForHtml((string)multiLine)

    /Jesper

  • Roberto Bianchi 137 posts 445 karma points c-trib
    Aug 26, 2015 @ 12:08
    Roberto Bianchi
    0

    Still it does not work

  • 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