ASP.NET MVC 4: Confirmation alert before delete:
This is the sample code for display a confirmation alert message before delete an employe detail.
In View:
In Script:
In Controller:
This is the sample code for display a confirmation alert message before delete an employe detail.
In View:
@Html.ActionLink("Delete", "DeleteEmp", new { id = item.Id }, new { onclick = " return DeleteConfirm()" })
function DeleteConfirm(){ if (confirm("Are you sure want to delete record")) return true; else return false; }
public ActionResult DeleteEmp(int id) { var empDelete = (from emp in dbml.M_Employees where emp.Id == id select emp).Single(); dbml.M_Employees.DeleteOnSubmit(empDelete); dbml.SubmitChanges(); return RedirectToAction("Index"); }
6 comments:
Nice and thanks :)
Excellent! Thank you very much!
MVC is awesome!
thanks- pretty useful
It works with actionlink, but how can it work with button?
its works
Thanks
Nice, clear information. Thank you.
Post a Comment
Share your thoughts here...