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 61 posts 210 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!

Please Sign in or register to post replies

Write your reply to:

Draft