Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Asp.Net Core TagHelper equivalent of Html.ActionLink with script

I want to prompt a confirmation dialog before deleting. I found this answer here that works great

@Html.ActionLink(
          "Delete",
          "Delete",
          new { id = post.OriginalPost.ID },
          new { onclick = "return confirm('Are you sure you wish to delete this post?');" });

but as I understand in Core one should avoid the use of ActionLinks. So are there any tag-helpers or different ways to do this?

like image 571
Maverick Meerkat Avatar asked Aug 02 '18 15:08

Maverick Meerkat


1 Answers

You would normally use the AnchorTagHelper:

<a asp-action="Delete" asp-route-id="@post.OriginalPost.ID" 
    onclick="return confirm('Are you sure you wish to delete this post?');">Delete</a>
like image 124
Camilo Terevinto Avatar answered Sep 30 '22 18:09

Camilo Terevinto