当DatePicker KendoUI中的Change事件发生时,我无法使.ajax()方法工作 - 不调用方法。请看一下。
<label for="start">Start Date:</label>
@(Html.Kendo().DatePicker()
.Name("start")
.Value(fromDate)
.Min("01/01/2010")
.Max("01/01/2015")
.Events(e => e.Change("startChange"))
)
<label for="end">End Date:</label>
@(Html.Kendo().DatePicker()
.Name("end")
.Value(toDate)
.Min("01/01/2010")
.Max("01/01/2015")
.Events(e => e.Change("endChange"))
)
<script type="text/javascript">
function startChange() {
var startDate = this.value();
var endDate = $("#end").data("kendoDatePicker").value();
$.ajax({
url: "/Home/SaleOrders",
type: "POST",
data: {
fromDate: kendo.toString(startDate, "d"),
toDate: kendo.toString(endDate, "d")
},
success: function (response) {
},
error: function (e) {
alert("error");
}
});
@*$.post('@Url.Action("SaleOrders", "Home")', { fromDate: startDate, toDate: $("#end").val() }); - I also tried with post method - but no luck*@
}
控制器方法:
public ActionResult SaleOrders(DateTime? fromDate, DateTime? toDate)
{
// ... get the list of orders here
return View(model);
}
我用[HttpPost]属性尝试了这个方法,但它没有帮助。