ASP.NET MVC binding decimal value

后端 未结 4 2025
既然无缘
既然无缘 2021-01-04 00:19

I\'m trying to figure out why framework refuses to bind \"1,234.00\" value to decimal. What can be the reason for it?

Values like \"123.00\" or \"123.0000\" bind suc

4条回答
  •  借酒劲吻你
    2021-01-04 01:12

    Based on a comment from an article about decimal model binding by Phil Haack here, I believe part of the answer to the "why" is that culture in browsers is complicated and you can't be guaranteed that your application's culture will be the same culture settings used by the user/ browser for decimals. In any case it is a known "issue" and similar questions have been asked before with a variety of solutions offered, in addition to the so: Accept comma and dot as decimal separator and How to set decimal separators in ASP.NET MVC controllers? for example.

提交回复
热议问题