Copied to clipboard

Flag this post as spam?

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


  • Jordy Vialoux 73 posts 103 karma points
    Jan 23, 2015 @ 23:22
    Jordy Vialoux
    0

    Umbraco 7 | If checkbox "checked" add class to body

    Hi Guys,

    I'm new to razor but not Umbraco and I'm wanting to know how to add a class to the body element if the user "checks" a checkbox within the generic properties tab. 

    I understand this is simple but unsure on the code to append to the body tag. 

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jan 24, 2015 @ 06:25
    Jan Skovgaard
    0

    Hi Jordy

    You should be able to achieve this by using the ternary operator something like this

    <div class="@(CurrentPage.myProperty != String.Empty ? "myStyleOne" : null)">
    

    This should only add the class if your property is not empty otherwise the class will be empty.

    Hope this hels (and works) :)

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft