I have a MVC 3 website and I need to set a warning with confirmation when user is trying to add a record for the same date. User clicks on a button on a view:
<input type="button" onclick="document.location.href = '@Url.Action("StartClock", "Time")'" value="Start Clock" />
Here is a code from controller. Button tat triggers this action is at StartWork view.
public ActionResult StartWork()
{
return View();
}
public ActionResult StartClock()
{
if (helper.IsDuplicate(1, DateTime.Now))
{
//here I want to trigger a confirmation popup or some warning
}
helper.Start(1, DateTime.Now);
return RedirectToAction("Index");
}
When it is a duplicate I want to trigger some kind of a popup with warning and options to proceed anyway or cancel.
I have tried rendering PartialView but it just rendered new view.
Any help much appreciated!
Try using a flag set in
ViewDatato indicate whether the confirm box should be shown in your view:Then in your view: