Nishant Rambhojun
Nishant Rambhojun

Reputation: 77

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

enter image description here

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

Where did I go wrong ?

Upvotes: 1

Views: 448

Answers (2)

Jeyhun Rahimov
Jeyhun Rahimov

Reputation: 3787

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>

Upvotes: 2

Mahmoud Darwish
Mahmoud Darwish

Reputation: 1161

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>

Upvotes: 3

Related Questions