我的javascript功能如下
function SelectVoucher(Vid, vDeptCode) {
var voucherID = Vid;
var vDeptCode = vDeptCode;
window.location.href = "@Url.Action("Edit_Voucher", "Voucher", new { id = voucherID }) ";
}
但是new { id = voucherID }
给出了一个错误:
当前上下文中不存在凭证ID。
答案 0 :(得分:3)
您可以通过以下方式传递它:
window.location.href = "@Url.Action("Edit_Voucher", "Voucher", new { id = voucherID,name = customerName }) ";
答案 1 :(得分:2)
见下面的例子
var firstname = "abc";
var username = "abcd";
location.href = '@Url.Action("Display", "Customer") ?
uname=' + firstname + '&name=' + username;