Copied to clipboard

Flag this post as spam?

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


  • Amir Khan 1199 posts 2567 karma points
    Jan 17, 2013 @ 22:40
    Amir Khan
    0

    Check if property exists and has value

    How do you go about checking if a property exists and has value? "HasValue(string)" seems to only check if the property exists at all?

     

    @if(@product.Node.HasProperty("productSalePrice")){
    <span class="price">Price: <span class="salePrice">@product.OriginalPrice.ToString("C")</span> @product.Node.GetProperty("productSalePrice")</span>
    } else {
    <span class="price">Price: @product.OriginalPrice.ToString("C")</span>
    }
  • Amir Khan 1199 posts 2567 karma points
    Jan 17, 2013 @ 22:50
    Amir Khan
    101

    Got it!

     

    @if(@product.Node.HasProperty("productSalePrice") && @product.Node.GetProperty("productSalePrice").Value != String.Empty)
  • 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