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 1282 posts 2739 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 1282 posts 2739 karma points
    Jan 17, 2013 @ 22:50
    Amir Khan
    102

    Got it!

     

    @if(@product.Node.HasProperty("productSalePrice") && @product.Node.GetProperty("productSalePrice").Value != String.Empty)
Please Sign in or register to post replies

Write your reply to:

Draft