I am calling a modal dialog. The dialog should perform an action in the code behind, then immediately close and show a notification in the parent window. I am using the following bit of code:

       SP.UI.Notify.addNotification(result, false);

The closing of the page is done by calling the following function at the end of the Page_Load:

private void Close(int status, string message)
    Page.Response.Write(string.Format("<script type=\"text/javascript\">window.parent.SP.UI.ModalDialog.commonModalDialogClose({0}, '{1}');</script>",status,message));            

This works fine on my own machine, but on some other environments, this does nothing. The modal dialog remains open. If I check the contents of the frame I see that the bit of javascript is present in the head of the page. So it seems my .aspx page is fine, but the javascript is missing something?

  • Have you tried to profile it in IE9? F12 > Profile, this might throw you some insights. Failing this Chromes profiler is a little more powerful. From the face of it I think you have approached it correctly. You might also want to check the browser engine used, SharePoint attempts to use the IE8 rendering engine, which just doesn't like executing some JavaScript.
    – Hugh Wood
    Dec 18, 2012 at 9:33

1 Answer 1


Mate, check out this post

You'll probably find out a possible solution.

  • 1
    Thanks! I didn't have need for the separate class, but by doing "Page.Response.Clear();" and using window.frameElement.commonModalDialogClose (as per that example) my issue is resolved. Dec 18, 2012 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.