SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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 '12 at 9:33
up vote 2 down vote accepted

Mate, check out this post

You'll probably find out a possible solution.

share|improve this answer
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. – Spongeroberto Squarepantalones Dec 18 '12 at 11:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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