سؤال

I got an action-link passing an ID to a Deletemethod in my controller.

@Html.ActionLink("Delete", "DeleteContent", new { xid = item.Id }) 

I would like som kind of "confirm action"-alert that gets triggered when the link is clicked. Lets say the alert has two options, "Delete" and "Cancel".

If the user hits cancel I dont want the method to excecute.

Any tips on how to accomplish that?

هل كانت مفيدة؟

المحلول

You can add a confirm box

@Html.ActionLink("Delete", "DeleteContent", new { xid = item.Id,onclick="return confirm('Are you sure you want to delete?');" }) 
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top