Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.ModalDialog.showModalDialog({
    url:'{SiteUrl}/_layouts/myproject/UserActions/myaction.aspx',
    dialogReturnValueCallback:function(status,result){
       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));            
    Page.Response.Flush();
    Page.Response.End();
}

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
add comment

1 Answer

up vote 2 down vote accepted

Mate, check out this post

You'll probably find out a possible solution.

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

Your Answer

 
discard

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.