我的MVC应用程序中有以下javascript函数,
function EditProducts(productId, orderId, employeeId, mode) { mode = "edit"; debugger; var url = '@Url.Action("Index", "Home", new { productId = "__productId__", orderId = "__orderId__", employeeId = "__employeeId__", Mode = "__mode__"})'; var params = url.replace('__productId__', productId).replace('__orderId__', orderId).replace('__employeeId__', employeeId).replace('__mode__', mode); window.location.href = params; }
但它不起作用.这是我的控制器代码,我在下面的vaiables中没有得到任何值,
public ActionResult Index(int productId, int orderId, int employeeId, string mode) { return View(); }
关于如何通过url.action传递多个参数的任何想法?
使用@ Html.Raw防止&符号转换为&
javascript内部代码
function EditProducts(productId, orderId, employeeId, mode) { mode = "edit"; debugger; var url = '@Html.Raw(Url.Action("Index", "Home", new { productId = "__productId__", orderId = "__orderId__", employeeId = "__employeeId__", Mode = "__mode__"}))'; var params = url.replace('__productId__', productId).replace('__orderId__', orderId).replace('__employeeId__', employeeId).replace('__mode__', mode); window.location.href = params; }