ProWorks Blog

Umbraco 4.5.2 Custom Create Control Fix in Custom Admin Trees

By  |  Tuesday, October 26, 2010  |  , , , , , ,  |  3 comments

Umbraco Developer TutorialWhile 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.

3 comments for “Umbraco 4.5.2 Custom Create Control Fix in Custom Admin Trees”

  1. Posted 10/26/2010 at 11:09:37 AM

    [...] This post was mentioned on Twitter by Jason Prothero, Jeroen Breuer. Jeroen Breuer said: RT @protherj: Blogged: &quot;Umbraco 4.5 Custom Create Control Fix in Custom Admin Trees&quot; - ProWorks Blog [...]

  2. Posted 9/30/2011 at 12:00:00 AM

    Glad we could help!

  3. Posted 9/30/2011 at 12:00:00 AM

    Hallelujah! I need this?you’re my savior.

Post a comment