Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Currency formatting not working

$
0
0

The data type and/or display format data annotations are not having any effect at the UI.  The code in the model is:

        [DataType(dataType:DataType.Currency)]
        [DisplayFormat(DataFormatString ="{0:C0}")]
        public decimal? Price { get; set; }

The HTML/razor code is

<p class="control-label">@Model.Price</p>

I'm using Core version 1.0:

"dependencies": {"Microsoft.NETCore.App": {"version": "1.0.1","type": "platform"
    },

There doesn't appear to be any other way around this either other than using strings and formatting the data going into the model (which in this case is feasible as it's read only, but obviously not all prices are going to be for display purposes in the future).

Paul


Viewing all articles
Browse latest Browse all 9386

Trending Articles