Thursday, February 27, 2014

Closing A SharePoint Modal Dialog

SharePoint Modal Dialog - Closing Difficulty

Creating a SharePoint modal dialog is relatively simple and straightforward.  Closing the modal dialog that is created?  Not so much... there are many posts around regarding solutions to this issue, most of which I found were not effective and did not work when server side code behind was associated with the modal dialog that was created and popped out.

Some of the solutions proposed included:

window.frameElement.cancelPopUp(); //Works on cancel dialog button
window.frameElement.commitPopup(); //Works on submit dialog button

In order to effectively close the modal dialog, the following example was found to be effective in my instance:


<SharePoint:ScriptLink Name="sp.ui.dialog.js" LoadAfterUI="true" Localizable="false" runat="server"></SharePoint:ScriptLink>

<script type="text/javascript">
    //<![CDATA[
    function LoadAlert(url) {
        var options =
            {
                url: url,
                width: 800,
                height: 1100,
                title: 'My Personal Info',
                showClose: false
            };
        SP.UI.ModalDialog.showModalDialog(options);
    }

    function CloseCallback(result, target) {
        CloseForm();
    }

    function CloseForm() {
        var dlg = SP.UI.ModalDialog.get_childDialog();
        //This is required to effectively close the child form on submit.
        dlg.close();

        return false;
    }
    // ]]>
</script>



Postings, A start

Postings and Rants

Precursor to collaborative distribution.

SharePoint at it's finest!

This is where I am going to attempt to provide insightful findings regarding the SharePoint office platform and the many ways it can be used and prepared in the effort to enhance modern day business practice.