本文介绍了ASP.NET MVC4教程/脚手架 - 验证和展示使用多种不同的语言环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用VS 2012 RC并试图跟随MVC4教程从这里开始:

I am using the VS 2012 RC and trying to follow the MVC4-tutorial from here:

http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/accessing-your-model%27s-data-from-a-controller

我得到输入有关电影的一些细节,然后点击创建按钮。然后得到一个错误:

I get to "Enter some details about a movie and then click the Create button." and then get an error:

"The value '9.99' is not valid for Price."

所以我想它需要一个小数逗号,而不是和9,99,而不是结果如下尝试:

So I figure it needs a decimal comma instead and try with 9,99 instead with the following results:

"The field Price must be a number."

所以我不知道如何进入的数量和满足验证检查。似乎有好几个。所以,我进入另一个9号(没有任何小数或小数字符),然后它的作品。

So I do not know how to enter the number and satisfy the validation checks. There seem to be several. So I enter another number 9 (without any decimals or decimal character) and then it works.

然后我preSS'编辑',看看我是否可以改变现在的数字。现在的价格是$ psented为p $

I then press 'Edit' to see if I can now change the numbers. The price is now presented as

9,00

带有小数点逗号和日期

with a decimal comma, and the date as

01.11.1989 00:00:00

下面的错误,然后立即显示,经过简单的复制日期和价格字段到剪贴板:

The following errors are then displayed immediately, after simply copying the date and price fields to the clipboard:

The field ReleaseDate must be a date.

The field Price must be a number.

和它再次无法保存。

所以我想,ASP.NET MVC脚手架自动要求号码使用文化不变(小数点),并用我的(德国)文化需要小数逗号格式化。它还要求日期被格式化的文化目不暇接,我猜是美国的日期格式。

So I guess, ASP.NET MVC scaffolding automatically requires that numbers are formatted using culture invariant (decimal point) and using my (German) culture which requires decimal comma. It further requires dates to be formatted culture invariantly which I would guess is the US date format.

然后显示时,在默认情况下使用当前(德国)文化。

Then when displaying, it uses the current (German) culture by default.

我遗憾的是使用一台计算机与德语区域设置。

I am unfortunately using a computer with German locale settings.

我想值使用当前的文化,它已经这样做可以显示。
但我也想了验证,其中似乎有好几个,接受任何有效的格式,或者至少是在当前的文化。

I would like the values to display using the current culture, which it already does.But I would also like the validators, of which there seem to be several, to accept any valid format, or at a minimum the format that is valid in the current culture.

什么是我们的最佳解决方案的实际应用(而不是教程)?

What is the best solution for this for a real application (as opposed to the tutorial)?

推荐答案

原来,本教程介绍了如何在本教程后面解决这个问题。

It turns out, the tutorial describes how to fix this later in the tutorial.

这篇关于ASP.NET MVC4教程/脚手架 - 验证和展示使用多种不同的语言环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 21:55