Copied to clipboard

Flag this post as spam?

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


  • ThomasBrunbjerg 90 posts 182 karma points
    Aug 21, 2017 @ 06:07
    ThomasBrunbjerg
    0

    Textarea datatype displaying <p><span> tags when shown in a partial view

    I have this textarea property value that I want shown in a partial view.

    @(item.GetPropertyValue("sommerhusKortBeskrivelse"))
    

    But when i load up my page, i get this result:

    http://i.imgur.com/TefDclH.png

    With the p and span tags showing in the body text. If i try to wrap the property value in a p tag, i get the same result.

    How do i display just the text of the property value?

  • Dan Diplo 1554 posts 6205 karma points MVP 5x c-trib
    Aug 21, 2017 @ 11:48
    Dan Diplo
    0

    Textareas are meant for plain text, not HTML. By default all content added to a text area is HTML encoded (for security).

    If you want HTML use a rich-text editor datatype and if you want plain text use a text area.

    If you really want to render HTML in a textarea then use:

    @Html.Raw(item.GetPropertyValue("sommerhusKortBeskrivelse"))
    
Please Sign in or register to post replies

Write your reply to:

Draft