所以我使用here的jQuery Time选择器插件。当我在视图中选择时间(例如:晚上11:48)并以调试模式提交时,我看不到传递给控制器的值。它始终为空值。我认为我的代码中存在问题,但无法解决。任何帮助表示赞赏。
@Html.EditorFor(model => model.MonStart, new { htmlAttributes = new { @class = "form-control time_element", @name = "timepicker", @id = "monStart" } })
型号:
public string MonStart { get; set; }
查看:
@model test.Models.Employee
@using Microsoft.AspNet.Identity
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.MonStart, "Monday: ", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.MonStart, new { htmlAttributes = new { @class = "form-control time_element", @name = "timepicker", @id = "monStart" } })
@Html.ValidationMessageFor(model => model.MonStart, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default"/>
</div>
</div>
</div>
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
<script src="@Url.Content("~/Scripts/timepicki.js")" type="text/javascript"></script>
<link href="@Url.Content("~/Content/timepicki.css")" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(document).ready(function () {
$("#monStart").timepicki();
});
</script>
}