Reputation:
public ActionResult Delete(int id)
{
using (RegMVCEntities obj = new RegMVCEntities())
{
var employee = obj.tblRegistrations.Where(m => m.ID == id).FirstOrDefault();
obj.tblRegistrations.Remove(employee);
obj.SaveChanges();
return RedirectToAction("Index");
}
}
I want to display a confirmation dialog box so it should ask like "Do you want to delete the record" and when yes is clicked then it delete the record. i am not getting how to do it.
Upvotes: 0
Views: 69
Reputation: 309
You can't show messages from a controller. That kind of thing has to be done from the view. So before you go to the action on the controller, you should show the confirmation dialog from the view first. If the user confirms you can go to the action, otherwise stay on the view (or alternitavly go to another action).
@Html.ActionLink("LinkText", "Action", "Controller", new { onclick = "return confirm('Message asking to confirm');"})
Upvotes: 0