ASP.NET MVC 3 not accepting my German date format settings - why?
I have a new ASP.NET MVC 3 project, and MVC and Razor are all brand new to me... can't figure this one out.
I have a dev machine on US-English Win7 x64, running English versions of VS 2010 Pro SP1 and ASP.NET MVC 3. But the app I'm working on is for a local client, and needs to be all in German and use all the formatting and defaults 开发者_Go百科commonly used here.
In my view model, I have defined a variable of type DateTime
and augmented it with some extra hints as to how to display (and edit) it - I need the Swiss-German date formatting, which is: day.month.year
(in that order, separated by dots .
- not slashes)
public class MyViewModel
{
[Display(Name = "Gültig am")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString="dd.MM.yyyy", ApplyFormatInEditMode=true)]
public DateTime ValidAt { get; set; }
}
(of course, there are more properties in that view model, but those aren't relevant just now)
In my Razor view, I simply use the default stuff set up by the ASP.NET MVC 3 Add View
T4 template:
@Html.EditorFor(model => model.ValidAt)
Trouble is: if I enter something like 13.06.2011
(13th of June, 2011) which I believe is valid and conforming to my display and editing formats, I am still getting a client-side validation saying that The value '13.06.2011' is invalid
- WHY???
There must be something really fundamental (and probably totally silly) that I'm missing here....
Even though I have set all of this up,
What do you use for client validation? Did you look at Combining validation methods in jQuery Validation plugin with "or" instead of "and" ?
精彩评论