Search code examples
htmljquerycssasp.net-mvc-5

Hyperlink is lost using <a> tag in ASP.NET MVC view


I am using ASP.NET MVC 5 and in my view, I am trying to add "Edit | Delete" functionality within a table. I am getting a hyperlink for my edit, but I don't get any hyperlink for delete.

Here is my markup in the view:

<td id="pagefunc">
    @Html.ActionLink("Edit", "Edit", new { id = item.POC_Id }) |
    <a data-record-id="@item.POC_Id" class="js-delete delete">Delete</a>
</td>

Here is the screen shot of the section, on which edit gives me a hyperlink but delete does not:

enter image description here

I am not sure what I am doing wrong and why I am not getting a hyperlink on hovering over the delete link


Solution

  • Try the following:

    <td id="pagefunc">
        @Html.ActionLink("Edit", "Edit", new { id = item.POC_Id }) |
         <a href="@Url.Action("Delete", "Delete", new { id = item.POC_Id })" class="js-delete delete">
                  <span>Delete</span>
         </a>    
    </td>