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

So far I have tried this:

Page.ClientScript.RegisterStartupScript(this.GetType(), 
 "closePage", 
 "window.returnValue='http://sp-pubdev:88/Resources/Images/testFile.png';
 alert(window.returnValue);
 SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK);", true
);

and this:

Page.ClientScript.RegisterStartupScript(this.GetType(), 
 "closePage", 
 "window.returnValue='http://sp-pubdev:88/Resources/Images/testFile.png';
 alert(window.returnValue);
 window.close();", true
);

With both of these I will see my alter, but the window never closes. Is there something else I need to be doing here?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

In code behind u close model popup like this

Response.Write("<script type='text/javascript'>window.frameElement.commitPopup();</script>");
                      Response.Flush();
                      Response.End();

I hope u use application page otherwise u not get Response object

share|improve this answer

I hope this helps :) http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010general/thread/f27a2eff-5588-42b2-b3f6-26303497166e/

EDIT

I found this blog and goes into detail on closing a modal dialog! http://blogs.perficient.com/microsoft/2012/01/sharepoint-2010-closing-a-modaldialog-manually-from-code-c-and-javascript/

share|improve this answer
    
Yeah they basically suggest the first method I was using. I tried adding the second parameter to see if that would make it work, but no dice. –  Abe Miessler Aug 16 '12 at 22:41
    
have you tried this: void btnOK_Click(object sender, EventArgs e) { this.Context.Response.Write("<script type='text/javascript'>window.frameElement.commitPopup();</script>"); this.Context.Response.End(); } social.technet.microsoft.com/Forums/en-US/… –  ali Sharepoint Aug 16 '12 at 23:02
    
also this should work: SP.UI.ModalDialog.commonModalDialogClose(1, 'Submitted'); –  ali Sharepoint Aug 16 '12 at 23:05

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.