28
I'm using ASP.NET MVC 3.
My ViewModel looks like this:
public class Foo
{
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd.MM.yyyy}", ApplyFormatInEditMode = true)]
public DateTime StartDate { get; set; }
...
}
In view, I have something like this:
<div class="editor-field">
@Html.EditorFor(model => model.StartDate)
<br />
@Html.ValidationMessageFor(model => model.StartDate)
</div>
StartDate is displayed in correct format, but when I change it's value to 19.11.2011 and submit the form, I get the following error message: "The value '19.11.2011' is not valid for StartDate."
Any help would be greatly appreciated!