How to close the sharepoint modal dialog opened from modal dialog? RRS feed

  • Question

  • Hi All,

    I have to implement nested sharepoint 2010Modal Dialog.

    Steps are as followed-

    1.     Opening modal dialog from list/allitems.aspx

    2.     Now modal dialog box opened

    3.      Now again opening another modal dialog from modal dialog opened in step 2.

    4.     Its opening well, but issue with close link on right Top corner(OOTB), javascript message – “SP.UI.DialogResult.close is null or object not found”

    5.  Have added below lines script to fix javascript issue.(even though it’s not required to add explicitly.

    <SharePoint:ScriptLink ID="ScriptLink1" Name="sp.js" runat="server" OnDemand="true" Localizable="false" /> 
    <SharePoint:ScriptLink ID="ScriptLink2" Name="sp.Core.js" runat="server" OnDemand="true" Localizable="false" /> 
    <SharePoint:ScriptLink ID="ScriptLink3" Name="sp.Ribbon.js" runat="server" OnDemand="true" Localizable="false" /> 
    <SharePoint:ScriptLink ID="ScriptLink4" Name="sp.Runtime.js" runat="server" OnDemand="true" Localizable="false" /> 
    <SharePoint:ScriptLink ID="ScriptLink5" Name="SP.UI.Dialog.js" runat="server" OnDemand="true" Localizable="false" />  

    6.     Created html button(close button) in second one dialog, and written code like this

    <input type="button" id="btnClose" value="Close" class="global-btn" onclick="javascript:commonModalDialogClose();" /> 

    function closebutton()



                return false;




    Even same code is working for first Modal dialog box opened from main page

    Any ideas would be greatly appreciated.





    Wednesday, October 12, 2011 12:45 PM

All replies

  • have you tried:





    • Proposed as answer by Anna Arykova Monday, July 23, 2012 8:44 AM
    • Unproposed as answer by Anna Arykova Monday, July 23, 2012 8:44 AM
    Thursday, November 3, 2011 5:15 PM
  • Looks like you've got a typo in your closeButton() function: SP.UI.DialogResult.close isn't a valid dialog result value. The choices are 'OK', 'cancel', and 'invalid'. See this page on MSDN:

    Thursday, November 3, 2011 6:34 PM

    Hi All,

    As I have mentioned in above post, close button is not working for second modal dialog box, even same code works for first model dialog box.I have also tried with above suggested approach, it didn't work for this scenario.

    Previously, I was opening second model dialog box from -link button, so the default close functionality was not working for  second model dialog.(reason still unknow)

    <asp:LinkButton ID="lblSubCategory" runat="server" />

    lnkFile.Attributes.Add("OnClick", "javascript:ShowModalDialog('page.aspx');");


    When I replaced link button with label control  and converted this label control into hyperlink from server side then default close button works for second model dialog box.:)


    <asp:Label ID="lblbook" runat="server"></asp:Label>

    C# code

    string_link= "javascript:Showbook('page.aspx');";
           string title=”title”;
           lblLink.Text = "<a href=\"#\" OnClick=\"" + _link + "\" tooltip=\"" + _title + "\">" + _title + "</a>";





    Tuesday, November 15, 2011 10:39 AM