Question

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

enter image description here

However when I click the button the breakpoint is not reached.

Where did I go wrong ?

Was it helpful?

Solution

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>

OTHER TIPS

You can change it like this, if you want to use 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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top