0

I have a problem in my ASP.NET Core MVC application. I am trying to create input control that will be pass decimal parameter "Weight". Here's my .cshtml code:

<label asp-for="Input.Weight"></label>
                <input asp-for="Input.Weight" type="number" step="any" min="20" class="form-control" />
                <span asp-validation-for="Input.Weight" class="text-danger"></span>

and below is my cs code:

[Required]
[DataType(DataType.Currency)]
[Display(Name = "Waga [kg]")]
public decimal Weight { get; set; }

Every time when I try to put decimal value, it becomes zero (does not matter if I use comma or dot). When I write integer value, it works OK. I didn't find answer anywhere.

1 Answers1

0

Problem was solved when I changed type 'decimal' to 'string' (ofc I added proper javascript to allow only decimals). But I still don't understand why my property Weight cannot be decimal...