剑道TimePickerFor不绑定到视图模型当使用时间跨度MVC

问题描述 投票:1回答:1

我有一个值得为用户提供了“一天的最佳配合时间”一周的某一天需要的应用程序。我想代表一天,在C#(就像DateTime.TimeOfDay对象一样)我不需要的日期,但也不想使用日期时间,并让用户看到的实际日期的时间跨度对象的那段时间。

现在,我有这个在我的模型:

[Required, Display(Name = "Start")]
    public TimeSpan StartTime { get; set; }
    [Required, Display(Name = "End")]
    public TimeSpan EndTime { get; set; }

我有这对于我的部分观点:

<div class="form-group col-xs-6 col-lg-4">
    @Html.LabelFor(m => m.StartTime, new { @class = "control-label" })
    @(Html.Kendo().TimePickerFor(m => m.StartTime).Interval(15).Culture("en-Us").HtmlAttributes(new { @class = "form-control" }))
    @Html.ValidationMessageFor(m => m.StartTime)
</div>
<div class="clearfix"></div>
<div class="form-group col-xs-6 col-lg-4">
    @Html.LabelFor(m => m.EndTime, new { @class = "control-label" })
    @(Html.Kendo().TimePickerFor(m => m.EndTime).Interval(15).Culture("en-Us").HtmlAttributes(new { @class = "form-control" }))
    @Html.ValidationMessageFor(m=>m.EndTime)
</div>
<div class="clearfix"></div>

我不断收到使用MVC的ModelState这种模式的错误:

的ErrorMessage =“值‘1:00 PM’是无效的开始。”

我不知道我在做什么错,智能感知说,剑道widget支持一个时间跨度为它的输入,但为什么不是这实际上结合的观点?

我所看到的这篇文章:Kendo Timepickerfor formatting not working

它不完全是我要找的,因为我觉得应该是代表一天的时间是无关的实际日期更简单的方法...任何帮助是非常感谢!

谢谢!

c# asp.net-mvc kendo-ui asp.net-mvc-5.1 kendo-ui-mvc
1个回答
0
投票

使用日期时间似乎工作像你说的@Saranga

不要太高兴它存储在数据库中的整个日期,因为它不是立即清除,然后,这只是仅仅的时间有关,但它的作品。

谢谢你的帮助!

© www.soinside.com 2019 - 2024. All rights reserved.