Copied to clipboard

Flag this post as spam?

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


  • Robert Bullock 15 posts 75 karma points
    Jul 27, 2021 @ 18:25
    Robert Bullock
    0

    Umbraco 8: Umbraco.If Helper

    I used the Umbraco.If() helper extensively in my templates. Nice shorthand way of switching rendered content or handling empty values.

    Any suggestions for a quick replacement?

  • Steve Kromer 11 posts 121 karma points
    Feb 15, 2022 @ 17:43
    Steve Kromer
    0

    You could use a simple c# if statement instead such as

    @if (singleColumn) { @Html.Raw("<div class='container'>"); } else { @Html.Raw("<div class='sub'>"); }
    
  • Tor Langlo 189 posts 532 karma points
    Nov 21, 2022 @ 00:02
    Tor Langlo
    0

    In Umbraco 9+ you can use Html.If() instead. Html is of type IHtmlHelper from asp.net core, and If() is implemented by Umbraco in the Umbraco.Extensions.HtmlHelperRenderExtensions class.

Please Sign in or register to post replies

Write your reply to:

Draft