Copied to clipboard

Flag this post as spam?

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


  • Arild Lindeflaten 12 posts 31 karma points
    Sep 04, 2015 @ 08:30
    Arild Lindeflaten
    0

    Javascript in document property (Umbraco 7.2.8)

    A customer wants to add javascript snippets to the page, and I have set up a textarea property on the document type. Problem is, only part of the script is generated on page

    The script:

    Complete script This is generated:

    Generated script

    Code I use:

      @Umbraco.Field("globalTrackingScript", recursive: true)
    

    I also tried using

    @Html.Raw(Model.Content.GetPropertyValue<string>("globaleTrackingScript", true))
    

    same result.

    I can see the complete script in the database.

    Is it a bug, or am I doing something wrong?

  • Jonathan 19 posts 101 karma points
    Sep 04, 2015 @ 08:35
    Jonathan
    0

    Hi Arild,

    We had a simular issue a while back. We had to cast the field output to string before rendering it in Html.Raw. Hopefully this also fixes your issue.

        string scripts = Umbraco.Field("globalTrackingScript", recursive: true).ToString();
    
        if (!string.IsNullOrWhiteSpace(scripts))
        {
            @Html.Raw(scripts);
        }
    
  • Arild Lindeflaten 12 posts 31 karma points
    Sep 04, 2015 @ 08:58
    Arild Lindeflaten
    0

    Thanks for the reply, but unfortunately that didn't work. Same problem.

Please Sign in or register to post replies

Write your reply to:

Draft