Copied to clipboard

Flag this post as spam?

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


  • Rayyan 46 posts 238 karma points
    Jul 05, 2017 @ 07:27
    Rayyan
    0

    Hide element when Field is null

    Hello there,

    I need to hide the following hyperlink when the field is empty, please advise, and thank you for your help.

    <a href="@Umbraco.Field("collCatalog")">Catalog</a> 
    
  • Mats Stam 66 posts 236 karma points
    Jul 05, 2017 @ 07:47
    Mats Stam
    100

    I usually prefer to get my values from @Model.Content

    There you'll have stuff like:

    @if (Model.Content.HasValue("collCatalog"))
    {
         <a href="@Model.Content.GetPropertyValue("collCatalog", "-defaultValue-")">Catalog</a>
    }
    
  • Rayyan 46 posts 238 karma points
    Jul 05, 2017 @ 07:53
    Rayyan
    0

    Awesome, a million thanks!

  • 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