English 中文(简体)
ASP. NET MVC 在使用浮动点号码时,GisModel把ci门捆绑起来。
原标题:ASP.NET MVC ViewModel binded decimal empty when using floating point numbers

我制造了一个含有价格的陈情门槛物。 当我向我的控制者表明,情况是:

  • Enter "15" -> ok! Controller receives 15.
  • Enter "15.00" -> not ok! Controller receives a null field.
  • Enter "15,00" -> validation error because the field should be formatted with a period (I just stick to one formatting type to avoid complexity for the time being).
  • Enter "15.00M" -> validation error, probably because it s not considered to be a number.

我如何确定这一点? 我想“15.00”是一种正确的价值,但我可以说明如何做到这一点。 我在互联网上找到了两套习惯模式的宾逊,但是他们做了一些工作。

最佳回答

解决这一问题最容易的方法是将语言放在网络中。 专案:

<globalization culture="en-us" uiCulture="en-us" />

页: 1

Why is it the easiest? This way the included JavaScript helpers can do validation without problems (which is done by assuming that numbers should be US formatted values), which is now (due to our changes) the same on the server. Therefore something that is valid on the client side will also be valid on the server side (statement only valid for simple cases and JavaScript enabled browsers).

所有其他选择都涉及对多国企业地方化进行更多的编辑、推广和知识。 3. 。

问题回答

创建一个没有绘制地图的类型领域,例如:

[NotMapped]
public string priceComputed {get;set}

然后,在你的控制员中,你将价值定在正确的领域。

price = convert.todecimal(pricecomputed)




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签