I will explain in this post how to get confirm message from user before delete record
View
@Html.ActionLink("Delete", "DeleteEmp", new { id = item.Id }, new { onclick = " return DeleteConfirm()" })
Script
function DeleteConfirm(){
if (confirm("Are you sure want to delete record"))
return true;
else
return false;
}
Controller
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");
}
No comments:
Post a Comment