Decimal numbers update when using other local

I have this model

public class SalesModelView
{
    [Key]
    public int SaleId { get; set; }
    public int ShopId { get; set; }
    public string ShopName { get; set; }

    [Display(Name = "Date")]
    public DateTime SaleDate { get; set; }

    [Required]
    [Display(Name = "Timer")]
    [Range(0, 24)]
    public int Hours { get; set; }
    [Required]
    [Display(Name = "Salg")]
    public Decimal Sales { get; set; }
    [Required]
    [Display(Name = "Behandlinger")]
    public Decimal Treatments { get; set; }

    [Display(Name = "Omsรฆtning")]
    public Decimal Turnover { get; set; }
    [Display(Name = "Oms./Timer")]
    public Decimal TurnoverHour { get; set; }
    [Display(Name = "Effektivitet")]
    public Decimal Efficiency { get; set; }
}

and in the Danish locale, the decimal is usually displayed as 280.800,00, therefore, .as a thousand and ,as a decimal place.

My view displays the correct stuff

enter image description here

But when returning to my model, I get .as a decimal separator, passing all the values:

enter image description here

( source image for better visualization )

So, the number is 546.400converted to546,4

I already tried with no luck to plug in the submit form and replace everything with .nothing, like

$("form").bind("submit", function() {
  $(".number").each(function(){
    var v = $(this).val(v).replace('.','');
    $(this).val(v);
  });
});

What technique do you use for such things?

P.S. Hanselman, , Controller, , View

+3
1

DefaultModelBinder . en-US. .

+2

All Articles