1

在我的国家(克罗地亚),货币值的格式如下:

123.456.789,00 千牛

我有 MVC 应用程序,它要求用户输入某物的价格。decimal?我的模型用变量表示该字段。当用户输入此号码时:

5.678,22

MVC 返回此错误消息:

值 xxx 对该字段无效。

尽管该数字的格式正确。在我将变量数据类型从更改decimal?为 justdecimal后,一切正常(用户可以输入数字 5.678,22 并且 MVC 不会返回错误)。

所以我的问题是:发生了什么事?这可能是 .NET 框架中的某种错误吗?我正在使用 .NET 框架 4.5。

4

1 回答 1

0

This Stack Overflow post may be able to assist you, or you can just more directly check this Blog by Phil Haack, he uses a customized model binder that detects your Culture Info when binding decimals.

于 2012-11-13T16:44:46.057 回答