我有这样的看法:
$('#datepicker').datepicker({
onSelect: function (date, inst){
$(this).parent('form').submit();
}
});
<form method="post" name="datepickerForm">
<div id="datepicker"></div>
</form>
Date Posted: @ViewBag.PostedDate
在控制器中,我有:
public ActionResult Index(int? datepickerForm) {
if(datepickerForm.HasValue) // this is always null
ViewBag.PostedDate = datepickerForm.Value;
}