1

I have a modal dialog that I call from my sender page:

function openCommentsDialog( ITEMID)
{
    var DropDownListValue = document.getElementById("HideVal").value;
    var options = SP.UI.$create_DialogOptions();
    options.url = "/_layouts/SRP/SRPChange2.aspx" + "?Type=" + DropDownListValue    + "&ItemID=" + ITEMID;        //"SRPChange.aspx" + "?Type=" + DropDownListValue +"&ItemID=" + ITEMID;
    options.height = 600;
    options.width = 800;
    options.allowMaximize = false;

    options.Title = "SRP Change Dialog";
    **options.dialogReturnValueCallBack = Function.createDelegate(null,  dialogCloseCallBack);**
    SP.UI.ModalDialog.showModalDialog(options);

}

This is the callback function on the sender page:

function dialogCloseCallBack(result, returnValue) {
    SP.UI.ModalDialog.RefreshPage(result);
}

On the dialog page I have dynamically added a "Close" button. I have tried client script and server script but the diaglogCloseCallBack function on the sender page never fires:

Client:

function closeWindow() {    
    SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.Close,null);
}

Server:

private void Close_OnClick(object sender, EventArgs e)
{
    this.Context.Response.Write("<script type='text/javascript'>window.frameElement.commonModalDialogClose(0,null);</script>");
    this.Context.Response.Flush();
    this.Context.Response.End();
}
  • Why have you added a close button dynamically? Won't the options.showClose = true work? – Vardhaman Deshpande Jul 2 '12 at 17:27
  • When I do that the Close button doesn't show up. – Walter Johnson Jul 2 '12 at 19:29
  • Even when I click the "X" to close the window, the delegate event doesn't fire. – Walter Johnson Jul 2 '12 at 20:11
  • Can you try changing your function to: function dialogCloseCallBack(result, returnValue) { alert(result); } and then clicking on the "x" to close. – Vardhaman Deshpande Jul 2 '12 at 20:35
  • The dialogCloseCallBack function doesn't fire. That is the problem. – Walter Johnson Jul 2 '12 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.