I've done this elsewhere in SharePoint, and it has worked perfectly, but it is not working on an Application Page presented as a modal in Central Administration.
I have one modal that has a button, and the button brings up a second modal. The code for that is:
function Add(webAppUri) { var targetUrl = "/_admin/CA/Add.aspx?WA=" + webAppUri + "&IsDlg=1"; var options = { url: targetUrl, args: null, title: 'Add', dialogReturnCallback: dialogCallback, }; SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options); function dialogCallback(dialogResult, returnValue) { __doPostBack('',''); } }
And on the child modal, I have a standard ASP.NET button that has a server-side click function:
protected void btnOk_OnClick(object sender, EventArgs e) { // ... do stuff ... var context = HttpContext.Current; if (HttpContext.Current.Request.QueryString["IsDlg"] == null) return; context.Response.Write("<script type='text/javascript'>window.frameElement.commitPopup();</script>"); context.Response.Flush(); context.Response.End(); }
Now, this closes the child modal correctly, but on my parent modal, the function dialogResult is never fired. On close of the child modal (when the OK button is pressed), I need to refresh the parent modal.
Trevor Seward, MCC
Follow or contact me at...



This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.