【发布时间】:2015-05-04 13:17:53
【问题描述】:
我有 buttonOnclick,它需要 2 个参数
$('.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 可以通过,但是 datepicker 总是为空。为什么?
【问题讨论】:
-
试试这个
window.location.href = "State/Form?numberNights="+numberNights"+&+"datepicker=" + datepicker;确保你的日期选择器有一个值!!
标签: jquery asp.net-mvc