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 1494 posts 1635 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 1505 posts 5911 karma points MVP 4x c-trib
    Feb 20, 2018 @ 14:05
    Dan Diplo
    0

    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 1494 posts 1635 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 1505 posts 5911 karma points MVP 4x 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...

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies