我有一个应用程序保证用户需要为一周中的特定日子提供“一天中的最佳时间”。我试图将一天中的那个时间表示为 C# 中的时间跨度对象(就像 DateTime.TimeOfDay 对象一样)我不需要日期,但也不想使用 datetime 并让用户看到实际日期.
现在我的模型中有这个:
[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' 对开始无效。"
我不确定我做错了什么,intellesense 说 kendo 小部件支持输入的时间跨度,但为什么这实际上没有绑定到视图?
我看过这篇文章:Kendo Timepickerforformatting not working
这不是我想要的,因为我觉得应该有一种更简单的方法来表示一天中与实际日期无关的时间......非常感谢任何帮助!
谢谢!