Im trying to post a form containing a dropdown with values and a starting and ending date and time. The problem is that when i post the form, it basicaly doesnt post. Instead of posting it is selecting the dateTimePicker input (because of the blue border in the html result). I can't put my finger on what is wrong. Thanks in advance!
DateTimePicker partials
@(Html.Kendo().DateTimePicker()
.Name("dtStartDatum")
.Value( DateTime.Today )
.Format( "dd-MM-yyyy HH:mm" )
.TimeFormat( "HH:mm" )
.DateInput( true )
)
@(Html.Kendo().DateTimePicker()
.Name("dtEindDatum")
.Value( DateTime.Now)
.Format( "dd-MM-yyyy HH:mm" )
.TimeFormat( "HH:mm" )
.Min(Model.dtStartDatum)
.DateInput(true)
)
Viewmodel with the 2 DateTimes:
public IEnumerable<vmPar> parVoerpunt { get; set; }
public IEnumerable<vmPar> parKanaal { get; set; }
public IEnumerable<vmPar> parAlarm { get; set; }
[DataType( DataType.DateTime )]
public System.DateTime dtStartDatum { get; set; }
[DataType( DataType.DateTime )]
public System.DateTime dtEindDatum { get; set; }
public int afdelingId { get; set; }
public int afdelingIdSelected { get; set; }
public int stalId { get; set; }
EDIT Somethimes it actually does post after repicking new dates like 10 times. When it posts it is the right value, but I don't know why it is not always posting.
I found my answer, sorry for the long wait, just reminded myself of this post.
Unobtrusive validation in Chrome won't validate with dd/mm/yyyy
This is my issue and my asnwer. The validator switched the month and day of month so that picking a date above day of week 12 gave an validation error (which was a very silent error, still can't find it). Really weird that the dd-mm-yyyy wont validate properly even if globalization is set up properly. Hope I can help someone.