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

Can I open SP.UI.ModalDialog within another ModalDialog?

I mean, I can, and opening works fine. What does not work, is closing second dialog. Neither default buttons for maximizing and closing window (in dialog's top bar) do anything, nor custom button with SP.UI.ModalDialog.close method.

Is it possible to successfully open and close a ModalDialog within ModalDialog?

share|improve this question

Yes it's possible. I have an example here that worked for me at least some time ago:

Function to open the first dialog:

function openRegAtt() {SP.UI.ModalDialog.showModalDialog(regAttOptions);}

JS inside the first dialog page:

function openAddPpl() {SP.UI.ModalDialog.showModalDialog(addPplOptions);}

Nothing special about it tbh, hard to say why it shouldn't work.

share|improve this answer
This is exactly how I open the dialog. But then I cannot close it. – Tschareck Apr 9 '13 at 13:07
up vote 0 down vote accepted

Found solution to this problem:

First dialog had asp:Button, that would open second dialog. The JS method for this was in OnClientClick. What I noticed, was that button click would reload first page again.

I changed asp:Button to HTML button: <input type="button" onclick="OpenSubDialog('/_layouts/SecondForm.aspx')">. Also in second dialog, save/close button now calls JS to close from code-behind:

 HttpContext context = HttpContext.Current;
 context.Response.Write("<script type='text/javascript'>window.frameElement.commitPopup()</script>");
share|improve this answer

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.