Copied to clipboard

Flag this post as spam?

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


  • Dan White 206 posts 510 karma points c-trib
    Dec 11, 2012 @ 18:27
    Dan White
    0

    Leave out Html.Raw

    Is there a reason to use Html.Raw on RTE content in 4.11 razor views?

    Html.Raw returns an HtmlString type.

    When I do

    @Model.Content.GetPropertyValue("bodyText").GetType()

    It returns System.Web.HtmlString.

    In order to use Html.Raw you need to first get the bodyText as a string:

    @Html.Raw(Model.Content.GetPropertyValue("bodyText").ToString()) 
    or
    @Html.Raw(Model.Content.GetPropertyValue<string>("bodyText"))

    I could be wrong, but to me it looks like we are converting an HtmlString to a String just to convert it back to an HtmlString.

    Am I missing something?

     

     

Please Sign in or register to post replies

Write your reply to:

Draft