I have this model:
[ModelBinder(typeof(DevExpressEditorsBinder))]
public class RegisterViewModel
{
[Required]
[DataType(DataType.Date)]
[Display(Name = "Дата рождения"), DisplayFormat(DataFormatString = "{0:dd.MM.yyyy}", ApplyFormatInEditMode = true)]
public DateTime Birthdate { get; set; }
}
And view code:
@*Html.EditorFor(s => s.Birthdate)*@
@Html.DevExpress().DateEditFor(s => s.Birthdate, settings =>
{
settings.Properties.DisplayFormatString = "dd.MM.yyyy";
settings.Properties.EditFormatString = "dd.MM.yyyy";
}).GetHtml()
The first variant (that's commented) works perfectly but I need to use DevExpress. And DevExpress DateEdit
sends the correct value only if I set the MM.dd.yyyy
format everywhere. Else, the validator output:
The field Birthdate must be a date.
How can I fix this issue?