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

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


This is the callback function on the sender page:

        function dialogCloseCallBack(result, returnValue) {


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:


<script type="text/javascript">

function closeWindow() {




private void Close_OnClick(object sender, EventArgs e)
        this.Context.Response.Write("<script type='text/javascript'>window.frameElement.commonModalDialogClose(0,null);</script>");


share|improve this question
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 posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.