-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有一个值! –