来自JQGrid,双击我试图按照以下代码将用户导航到新页面
ondblClickRow : function (id) {
location.href = '<% = Url.Action("Index","MyFeature") %>/' + id;
}
代码错误我们
生成的网址是
http://localhost:8080/MyFeature.mvc/9a1347dc-60b0-4b3b-9570-9ed100b6bc6a
在控制器完成操作后添加索引但是有更好的方法来执行此操作
location.href = '<% = Url.Action("Index","MyFeature") %>/Index/' + id;
http://localhost:8080/MyFeature.mvc/Index/9a1347dc-60b0-4b3b-9570-9ed100b6bc6a
答案 0 :(得分:1)
您可以使用一些将在客户端上替换的占位符:
ondblClickRow : function (id) {
var url = '<%= Url.Action("Index", "MyFeature", new { id = "__id__" }) %>';
window.location.href = url.replace('__id__', id);
}