Copied to clipboard

Flag this post as spam?

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


  • Biagio Paruolo 1594 posts 1825 karma points c-trib
    Feb 20, 2018 @ 13:52
    Biagio Paruolo
    0

    Umbraco 7.7.6: Check RTE if is null...

    I tried some test but I'm not able to check if RTE has no value and it's null. This is my test:

    if ((!Model.Content.IsNull("bodyTextRichEditor")) && Model.Content.HasValue("bodyTextRichEditor")){
                                          @Umbraco.Field("bodyTextRichEditor")
                                       }
    
  • Dan Diplo 1554 posts 6205 karma points MVP 5x c-trib
    Feb 20, 2018 @ 14:05
    Dan Diplo
    1

    Model.Content should be of type IHtmlString when you have rich text content.

    So one way to check would be:

    var html = Model.Content.GetPropertyValue<IHtmlString>("bodyTextRichEditor");
    
    if (html != null && !String.IsNullOrEmpty(html.ToString())
    {
         <div>@html</div>
    }
    
  • Biagio Paruolo 1594 posts 1825 karma points c-trib
    Feb 20, 2018 @ 19:09
    Biagio Paruolo
    0

    Not work

    Exception Details: System.ArgumentNullException: Value cannot be null. Parameter name: child

  • Dan Diplo 1554 posts 6205 karma points MVP 5x c-trib
    Feb 20, 2018 @ 20:09
    Dan Diplo
    0

    Post the actual code you are using, then and the line that raises this exception. The code I posted definitely does work, so it must be something else in the context of what you are doing...

Please Sign in or register to post replies

Write your reply to:

Draft