-1
我有buttonOnclick,這需要2個參數如何從@ Url.Action參數傳遞給控制器
$('.Conteiner').on("click", ".Button", function() {
window.location.href = '@Url.Action("Form", "State", new {numberNights, datepicker})';
});
我需要從@ Url.Action參數傳遞給控制器
我的控制器:
public ActionResult Form(int numberNights, string datepicker)
{
@ViewBag.NumberNights = numberNights;
@ViewBag.DatePicker = datepicker;
return View();
}
參數numberNights是通過確定,但日期選擇器始終爲空。爲什麼?
試試這個'window.location.href =「State/Form?numberNights =」+ numberNights「+&+」datepicker =「+ datepicker;'確保你的datepicker有一個值! –