I have MVC5 application and I am using kendo time picker to show time in 12 hr format. The ccorresponding model property is of type TimeSpan. When i submit the chosen time to server, the MVC model binding throws error
The value 'XXX' is not valid for 'PropertyName'.
cshtml
@(Html.Kendo().TimePickerFor(x => x.OrderTime) .Value("8:00 PM") .Min("12:00 AM") .Max("11:30 PM") .Format("hh:mm tt"))model
public class MyModel { public TimeSpan OrderTime {get;set;} }Note that if i remove Format method from the timePicker and submit the time in 24 hr format then i get chosen timespan value on server
5 Answers, 1 is accepted
I tried to replicate the issue locally but I was unable to. Could you please provided a small runnable sample where the issue could be replicated in order to investigate it locally?
I am looking forward to your reply.
Regards,
Kostadin
Telerik
*rephrased
I think there is a issue with time picker control when you try to bind Property of type TimeSpan. To fix this issue i have to change the type of the property to DateTime and then add data type attribute as [DataType(DateType.Time)]
I think there is a issue with time picker control when you try to bind Property of type TimeSpan. To fix this issue i have to change the type of the property to DateTime and then add data type attribute as [DataType(DateType.Time)]
I prepared a small sample which is working correctly on my end. Could you please try replicating the issue either in my sample or in a small runnable one in order to investigate the issue locally.
Regards,
Kostadin
Telerik