Copied to clipboard

Flag this post as spam?

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


  • jaco steketee 30 posts 187 karma points
    Dec 28, 2016 @ 09:03
    jaco steketee
    0

    Hi, im trying to create an if statement on a true false field. But its driving me mad... i keep getting errors and i dont quite understand how this works. Can someone please help me

    ive created a truefalse field named rolstoel. in my template i try:

    @if(Umbraco.Field.GetPropertyValue("rolstoel")==true)
    {
    <li><i class="icon_set_1_icon-13"></i>Toegankelijk</li>
    } 
    

    Thanks Jaco

  • Dennis Adolfi 1082 posts 6446 karma points MVP 5x c-trib
    Dec 28, 2016 @ 09:07
    Dennis Adolfi
    100

    Hi Jaco.

    So the problem is that "GetPropertyValue" returns a object, and you are comparing it against a boolean.

    Try the following:

    @if (Model.Content.GetPropertyValue<bool>("rolstoel"))
    {
        <li><i class="icon_set_1_icon-13"></i>Toegankelijk</li>
    } 
    

    Best of luck!

  • jaco steketee 30 posts 187 karma points
    Dec 28, 2016 @ 09:20
    jaco steketee
    1

    Great!!, this works perfect.Thank you very much Dennis!

  • Dennis Adolfi 1082 posts 6446 karma points MVP 5x c-trib
    Dec 28, 2016 @ 09:33
    Dennis Adolfi
    0

    Awesome jaco! Glad I could help!

    Have a great day!

Please Sign in or register to post replies

Write your reply to:

Draft