Copied to clipboard

Flag this post as spam?

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


  • Mark Evans 86 posts 116 karma points
    Aug 22, 2014 @ 10:38
    Mark Evans
    0

    checking a property value

    i am trying to check on the value of a property in order to set some variables.

    however in this example (banneroption is a dropdown) i have set it to be "Image Only" but the code always goes to the else option... so i cannot be checking for the value correctly.... 

    this is the code i am trying

      if (@Model.Content.HasValue("bannerOption").Equals("Image only"))

        {

            imageWidth = 960;

            imageHeight = 180;

        }

        else

        {

            imageWidth = 785;

            imageHeight = 180;

        }

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Aug 22, 2014 @ 10:40
    Jeavon Leopold
    0

    Try like this:

    @{    
        if (Model.Content.HasValue("bannerOption") && Model.Content.GetPropertyValue<string>("bannerOption").Equals("Image only"))
        {
            imageWidth = 960;
            imageHeight = 180;
        }
        else
        {
            imageWidth = 785;
            imageHeight = 180;
        }
    }
    
  • Mark Evans 86 posts 116 karma points
    Aug 22, 2014 @ 10:51
    Mark Evans
    0

    thanks very much, its working correctly now....

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Aug 22, 2014 @ 13:48
    Jeavon Leopold
    0

    Great!

Please Sign in or register to post replies

Write your reply to:

Draft