Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi all
I am displaying an integer as a string and adding a $ to the start of the string to show that it is a currency.
@if (p.GetPropertyValue<string>("salePrice") == "0") { <span class="price">TBA</span> } else { <span class="price">[email protected]("salePrice")</span> }
I was wondering if there is a way to format the saleprice directly to a currency format.
Thanks in advance
Hugh
Hi Hugh,
Assuming you are storing salePrice as a TextString but entering decimal values (maybe validating with regex?) then this should work ok:
@{ var salePrice = p.GetPropertyValue<decimal>("salePrice"); if (salePrice == 0.00m) { <span class="price">TBA</span> } else { <span class="price">@string.Format("{0:C}", salePrice)</span> } }
C is the currency format specifier, see here for more info
Jeavon
it tool late for you but may be helpful to someone else,
what I have done is that
@if (CartProductNode.HasValue("salePrice")) { decimal ProdsalePrice; decimal.TryParse(CartProductNode.GetProperty("salePrice").Value, out @ProdsalePrice); $ @ProdsalePrice.ToString("0.00") }
BJ,
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Partial View Currency Format
Hi all
I am displaying an integer as a string and adding a $ to the start of the string to show that it is a currency.
@if (p.GetPropertyValue<string>("salePrice") == "0")
{
<span class="price">TBA</span>
}
else
{
<span class="price">[email protected]("salePrice")</span>
}
I was wondering if there is a way to format the saleprice directly to a currency format.
Thanks in advance
Hugh
Hi Hugh,
Assuming you are storing salePrice as a TextString but entering decimal values (maybe validating with regex?) then this should work ok:
C is the currency format specifier, see here for more info
Jeavon
Hi Hugh,
it tool late for you but may be helpful to someone else,
what I have done is that
BJ,
is working on a reply...