Copied to clipboard

Flag this post as spam?

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


  • Christine 115 posts 288 karma points
    Apr 07, 2014 @ 16:22
    Christine
    0

    How to hide a div in Umbraco 7

    Hello,

    I'm using Umbraco V7

    I've been looking in the forum for this, but I think mine is so simple and the other's that i've read are so much more complex, i have not found anything that has helped me yet.

    I just want to hide a div if there is no content.  For example:

    <div class="feature">

    <p>@Umbraco.Field("sbFeatureBox")</p>

    </div>

    Because feature has background styles, if there is no content, it is still visible so this is why I need to hide it.

    Thanks in advance for your help.

  • Jeavon Leopold 3008 posts 13221 karma points MVP 7x admin c-trib
    Apr 07, 2014 @ 16:45
    Jeavon Leopold
    101

    Hi Christine,

    You could do this:

    @if (CurrentPage.HasValue("sbFeatureBox"))
    {
        <div class="feature">
            <p>@Umbraco.Field("sbFeatureBox")</p>
        </div>
    }
    

    Jeavon

  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    Apr 07, 2014 @ 16:46
    Jan Skovgaard
    0

    Hi Christine

    Why not avoid writing out the entire

    if the sbFeatureBox is empty?

    Try this

    @if(CurrentPage.HasValue("sbFeatureBox")){
        <div class="feature">
             <p>@Umbraco.Field("sbFeatureBox")</p>
        </div>
    }
    

    Does that help? :)

    You should bookmark the RazorCheatSheet or download it btw.

    /Jan

  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    Apr 07, 2014 @ 16:47
    Jan Skovgaard
    1

    Too slow! H5yr Jeavon :)

    /Jan

  • Christine 115 posts 288 karma points
    Apr 07, 2014 @ 17:04
    Christine
    0

    Thanks that worked!  and I will bookmark that CheatSheet :)

  • Christine 115 posts 288 karma points
    Apr 07, 2014 @ 17:05
    Christine
    0

    Thanks that worked!  and I will bookmark that CheatSheet :)

  • 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