[英]Decimal value on HTML arrives as integer in C# .NET MVC
I have an input for decimal values in HTML: 我在HTML中输入了十进制值:
<input type="number" step="0.01"/>
My model and my variables in C# are declared as decimal as well. 我的模型和C#中的变量也都声明为十进制。 But when I, for example, input a number such as 0,15 I get the value of 15 instead of the original 0,15 on my Controller.
但是,例如,当我输入一个数字(例如0,15)时,我得到的值是15,而不是控制器上原始的0,15。
I'm posting the data using the form method="post" from HTML 我使用HTML中的method =“ post”形式发布数据
The model is: 该模型是:
public decimal Value { get; set; }
What can I do to receive 0.15 as the value in my controller? 如何在控制器中接收0.15作为值?
Give the number input with dot "." 输入带有点“。”的数字。 not comma ","
不是逗号“,”
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/decimal https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/decimal
For example, C# decimals are given like this, decimal myMoney = 300.5m;
例如,C#十进制是这样给出的,
decimal myMoney = 300.5m;
使用jQuery maskMoney插件解决了问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.