0
我不知道如何通过函数javascript打开视图传递参数。例如:打开与通参数类别ID视图DetailProduct和产品ID如何在mvc 4中打开查看传递参数?
function DetailProduct(cid, pid) {
window.location.replace('@Url.Action("Detail", "Product", new { CategoryID = cid , ProductID = pid })');
}
我得到错误The name cid does not exist in the current context
和The name pid does not exist in the current context
感谢这么多。
YOUT能后的控制器中相应操作的代码? –
'@ Html.Action()'是剃须刀代码,并在传递给视图之前在服务器上进行评估。 'cid'和'pid'是javascript变量,在那个时候甚至不存在。您不能将它们添加为路由参数。您需要手动生成url =例如''@ Url.Action(“Detail”,“Product”)'+'?CategoryID =“+ cid' –