While working towards getting the Commerce for Umbraco project working in Umbraco 4.5.2 I encountered an issue that didn't appear to have an obvious fix. Luckily, a dive into the Umbraco source code provided an answer.
Commerce for Umbraco (C4U) has two custom creation dialogs for the Coupons and the Products. In Umbraco 4.0.x the dialog was closed after creation of the coupon/product and the tree refreshed by injecting the following javascript:
if (returnUrl == "") { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "refresh", "<script>\ntop.reloadCurrentNode();\ntop.closeModal();</script>"); } else { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "refresh", "<script type=\"text/javascript\">\ntop.reloadCurrentNode();\ntop.right.location.href = '" + returnUrl + "';\ntop.closeModal();</script>"); }
However, this didn't work in 4.5.2. I always thought this was a bit hacky, and although the code is probably actually doing the same thing the new way looks cleaner:
BasePage.Current.ClientTools .ChangeContentFrameUrl(returnUrl) .ChildNodeCreated() .CloseModalWindow();
You will need to use the following namespaces as well:
using umbraco.cms.helpers; using umbraco.BasePages;
So that is how you close and refresh a custom create dialog in your custom admin tree in Umbraco 4.5.2.
Feel free to ask questions in the comments.
[...] This post was mentioned on Twitter by Jason Prothero, Jeroen Breuer. Jeroen Breuer said: RT @protherj: Blogged: "Umbraco 4.5 Custom Create Control Fix in Custom Admin Trees" - ProWorks Blog http://ow.ly/2ZGyf [...]
Glad we could help!
Hallelujah! I need this?you’re my savior.
ProWorks Corporation - Mon 20 May 13 @ 21:25...We stop and take a moment to think of all those affected by the events in Oklahoma
ProWorks Corporation - Mon 20 May 13 @ 16:08Have you seen the changes to your Google+ page? Here is what you need to know. http://t.co/OkffstWqSy Thx again to @BethMcShane