[英]Decimal editor issue ASP.NET MVC
I'm currently stuck with a stupid problem, tried multiple solutions but it's still not working... 我目前遇到一个愚蠢的问题,尝试了多种解决方案,但仍然无法正常工作...
I'm currently on an ASP.NET MVC project and one of my classes needs a decimal as type so I created it like that : public decimal level { get; set; }
我目前在一个ASP.NET MVC项目,我的课的人需要一个小数类型,所以我创造了它这样的:
public decimal level { get; set; }
public decimal level { get; set; }
Then when I need to create a new object that contains this attribut , I use this on my view : <input type="number" name="level" step="any" min="1"/>
I also tried with an editorFor but in both cases, I got this message : 然后,当我需要创建一个包含该属性的新对象时,在视图上使用它:
<input type="number" name="level" step="any" min="1"/>
editorFor,但在两种情况下,我都收到以下消息:
The value '2.1' is not valid for level.
值“ 2.1”对于级别无效。
I've tried with 2.1 or 2,1 ( my culture is fr-FR) but both don't work and send the exact same error message... Can someone explains me why ? 我尝试使用2.1或2,1(我的文化是fr-FR),但都无法正常工作并发送完全相同的错误消息...有人可以解释我为什么吗?
Thanks in advance and have a nice day ! 在此先感谢您,祝您愉快!
It should be 2.1M for decimal. 十进制应为2.1M。 You have to put the letter M after the number.
您必须在数字后加上字母M。 If it was declared as float, it should have been 2.1F
如果声明为float,则应为2.1F
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.