@Html.ActionLink("Edit", "Edit", new { id = item.Id }, new { data_id = "edit_" + item.Id })
I hope this is the right syntax. The idea is to intercept the click of one of those anchor link and be able to tell which one was clicked, then extract the id.
I have other anchor tags in the page. How do I select this particular one?
There are two ways.
@Html.ActionLink("Edit", "Edit",
new { id = item.Id },
new { data_id = item.Id, id = item.Id })
$('a').click(function(){
alert($(this).data("id")); // alerts data-id attribute
//or
alert(this.id); // this alerts Id attribute
});