我想从jQueryUI datepicker绑定选定的日期到要在控制器中使用的模型,但其返回null。我能够检索选定值时的FormCollection使用绑定选定的日期从jqueryui datepicker到型号
视图模型
public class EmpViewModel
{
public int EmpId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public DateTime DateOfBirth { get; set; }
}
查看
<div class="col-md-10">
@Html.EditorFor(model => model.DateOfBirth,
new { htmlAttributes = new { @class = "form-control datefield" } })
</div>
控制器
public ActionResult Create(EmpViewModel emp)
{
}
试过下面的文章中的方法,但couldn”让它工作 http://www.asp.net/mvc/overview/older-versions/using-the-html5-and-jquery-ui-datepicker-popup-calendar-with-aspnet-mvc/using-the-html5-and-jquery-ui-datepicker-popup-calendar-with-aspnet-mvc-part-4
脚本
<script>
$(function() {
$(".datefield").datepicker();
})
</script>
该教程是五岁什么你的MVC版本?请粘贴您的'EmpViewModel' – naveen
@naveen - MVC 5,包含viewmodel – user3543878
显示您为datepicker连线的jQuery代码。 – Jecoms