Holds all previous page field values in a hidden field when posted to from a previous page with the intention of returning back to the parent with all the "unsaved" values still on the page.
Show an edit button on the page which collects all fields and navigates to an Edit action ready for returning.
The action to navigate to when editing.
Sets the page to return to after a pop up return. This is placed on the parent page to be used by the <pop-up /> tag on the child page.
The action to navigate back to after editing.
Used exclusively for a Pop Up return page called Views / Shared / PopUpReturn.cshtml when returning to a different controller after a Pop Up.
Helper functions for Pop Up.
public static class PopUpHelper
public static bool HasPopUp(HttpContext httpContext)
Does the posted data contain a PopUp?
public static string PopUpFrom(HttpContext httpContext)
Returns the name of the PopUp control that is the parent of this form.
public static T Parse<T>(HttpContext httpContext) where T : new()
Parses a PopUp into the provided type.
public static void SetSamePage(dynamic viewBag)
Flag that the SamePage property should be set to true and so do not reencode the values a second time.
public static void SetReturnFromPopUpChild(dynamic viewBag)
Flag that the ReturnFromPopUpChild property should be set to true and so do set a popup field on the page with remaining values for other pages.
To use this control put the <pop-up /> control on the child page.It will encode all the fields and make them available for a return.
To return you can optionally in C# check PopUpHelper.HasPopUp() to see if this has a return. If so then you can switch (PopUpHelper.PopUpFrom()) to get the calling page as defined in the PopUpFrom helper.
To return to same controller use Parse<> to obtain the model.
To return to a different controller call a PopUpReturn page which has
<pop-up />public ActionResult MyItemSet{ if (Model.IsValid) { ... } else { var p = PopUpHelper.Parse<ModelGet_Result>(); PopUpHelper.SetSamePage(); return View("MyView", p); }}<pop-up-from current-view="/Area/MyController/Action" /><pop-up />public ActionResult EditReturn(){ if (PopUpHelper.HasPopUp()) { switch (PopUpHelper.PopUpFrom()) { case "/Area/MyController/Action": ViewBag.Action = "EditPopUpReturn"; ViewBag.Controller = "MyController"; ViewBag.Route = "MyArea"; // use "" if no area. break; default: return RedirectToAction("Index") } return View("PopUpReturn") } else return RedirectToAction("Index");}@using ShareIt.Library@using (Html.BeginForm(PopUpHelper.GetReturnAction(ViewBag), PopUpHelper.GetReturnController(ViewBag), new { area = PopUpHelper.GetReturnRoute(ViewBag) })){ @Html.AntiForgeryToken() <pop-up-return />}<pop-up-from current-view="/Area/MyController/Action" /><pop-up /><pop-up-from current-view="/Area/MyChildController/Action" /><pop-up />public ActionResult EditReturn(){ if (PopUpHelper.HasPopUp()) { switch (PopUpHelper.PopUpFrom()) { case "/Area/MyController/Action": PopUpHelper.SetReturn("EditPopUpReturn", "MyController", "MyArea"); PopUpHelper.SetReturnFromPopUpChild(); break; default: return RedirectToAction("Index") } return View("PopUpReturn") } else return RedirectToAction("Index");}@using ShareIt.Library@using (Html.BeginForm(PopUpHelper.GetReturnAction(ViewBag), PopUpHelper.GetReturnController(ViewBag), new { area = PopUpHelper.GetReturnRoute(ViewBag) })){ @Html.AntiForgeryToken() <pop-up-return />}