[英]Url.Action not responding
I have an edit button implemented in an tag as 我在标签中实现了一个编辑按钮
<li><a id="nospin" onclick="'@Url.Action("Index", "LoadProduct", new { productid = Model.Products[i].ProductId})'" style="cursor:pointer;cursor:hand">Edit</a></li>
The controller where I wanted it to break is as in the screenshot 我想要破坏的控制器如屏幕截图所示
However when I click the button the breakpoint is not reached. 但是,当我单击按钮时,未达到断点。
Where did I go wrong ? 我哪里做错了 ?
Instead of 代替
<li><a id="nospin" onclick="'@Url.Action("Index", "LoadProduct", new { productid = Model.Products[i].ProductId})'" style="cursor:pointer;cursor:hand">Edit</a></li>
Use 采用
<li><a id="nospin" href='@Url.Action("Index", "LoadProduct", new { productid = Model.Products[i].ProductId})' style="cursor:pointer;cursor:hand">Edit</a></li>
You can change it like this, if you want to use onclick()
: 如果要使用
onclick()
,可以这样更改:
<li><a id="nospin" onclick="redirectIndex('@Model.Products[i].ProductId')" style="cursor:pointer;cursor:hand">Edit</a></li>
<script>
function redirectIndex(id)
{
window.location.href = '@Url.Action("Action", "Controller")/' + '?productid=' + id;
}
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.