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

So far I have tried this:

 SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK);", true

and this:

 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
up vote 6 down vote accepted

In code behind u close model popup like this

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

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

share|improve this answer

I hope this helps :)


I found this blog and goes into detail on closing a modal dialog!

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(); }… – 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


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.