views:

129

answers:

1

Hey guys,

I've a small question on ASP.NET MVC 2. I'm using Data Annotations on my Presentation Model and its model binder per default. But one step back, I want to do the most elementary thing: validation of the data type.

Let's say I have an "int ID" on my model and want to edit the according entity in my view. If I enter something wrong like "foo", then I get a model error back, but the validation message is on English. I want to have this message in other languages, too. How can I do this?

I remember that in MVC 1 I've written a custom model binder which checks the data types, but that's not what I want to do (at least not in MVC 2). Thus I hope there is a better way...

Thanks, Matthias

A: 

Model Validation with Localization

http://helios.ca/2010/02/17/asp-net-mvc-2-model-validation-with-localization/

David Liddle
First thanks for your answer. But it seems not to work for me (or I've got something wrong). If I want to have a specific culture, say "de-DE", then I modify my web.config to include: <globalization uiCulture="de" culture="de-DE" />. But the message is still English. Setting culture via Thread.CurrentThread.CurrentUICulture = new CultureInfo("de-DE"); in global.asax doesn't work as well, the error message remains English. Any suggestions?Thanks, Matthias
Matthias
It's not possible to define a custom message, is it?
Matthias