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?

2 Answers 2


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.

  • This is exactly how I open the dialog. But then I cannot close it.
    – Tschareck
    Commented Apr 9, 2013 at 13:07

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>");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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