Copied to clipboard

Flag this post as spam?

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


  • John Dawson 24 posts 146 karma points
    Jan 31, 2019 @ 09:37
    John Dawson
    0

    How to maintain formatting from the Document Type into modal content

    Hi, I have a Team Members section of the site with portrait, name and position for each member. When you click the portrait, it loads a modal with a bio. I have tried the Property Editor as textarea and Richtext editor but it won't pull the formatting through in either case.

    With textarea it just ignores the formatting, and with Richtext editor it adds all the HTML tags to the text. I'm not sure what I'm doing wrong here...?

    "Bio" property within doctype Team Member

    How the modal displays

  • Rhys Hamilton 140 posts 942 karma points
    Jan 31, 2019 @ 11:37
    Rhys Hamilton
    100

    I'm not sure how you're calling your bio property without seeing the code, but I'm assuming you're retrieving it as a string?

    If so, you could wrap it in Html.Raw()to strip the tags, like so:

    var rteText = "<p>String with paragraphs</p>";
    @Html.Raw(rteText) // Stripped
    @rteText // Unstripped
    

    Hope this helps!

  • John Dawson 24 posts 146 karma points
    Jan 31, 2019 @ 11:41
    John Dawson
    1

    Great, thanks! I was pulling through the bio via var bio = node.GetPropertyValue("bio").NullSafeToString(); so then in the modal-body called <div class="modal-body"><p>@Html.Raw(bio)</p></div>, which worked!

    Thanks for your help!

Please Sign in or register to post replies

Write your reply to:

Draft