ASP.NET MVC4 Tutorial / Scaffolding - validation and mapping use several different locales

I am using VS 2012 RC and trying to follow the MVC4 manual here:

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

I get β€œEnter some movie information and click the Create button. And then get the error message:

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

So, I suppose he needs a decimal point instead, instead try the following results instead of 9.99:

 "The field Price must be a number." 

Therefore, I do not know how to enter a number and perform validation checks. It seems there are several. So I entered another number 9 (without decimals or decimals) and then it works.

Then click "Change" to see if I can now change the numbers. Price is now presented as

 9,00 

with decimal point and date as

 01.11.1989 00:00:00 

The following errors appear immediately after simply copying the date and price fields to the clipboard:

 The field ReleaseDate must be a date. 

and

 The field Price must be a number. 

and again it’s impossible to save.

Thus, I think ASP.NET MVC scaffolds automatically require numbers to be formatted using the culture invariant (decimal point) and using my (German) culture, which requires a decimal point. It also requires that dates be a formatted culture, which I believe is the date format in the United States.

Then, when displaying, the current (German) culture is used by default.

Unfortunately, I use a computer with German language settings.

I would like the values ​​to be displayed using the current culture that it is already doing. But I would also like to see validators, of whom there seem to be several, accept any valid format, or at least a format that is valid in the current culture.

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

+4
source share
2 answers

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

+2
source

You are most likely using a culture that is defualt from your PC culture. You can declare a default culture if you want, i.e. us-en.

See http://everymanprogrammer.com/index.php/asp-net-easily-make-your-web-application-multilingual-part-2/

0
source

All Articles