Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to refresh a parent page after closing sharepoint dialog?

How to refresh a parent page after closing sharepoint dialog? Here is my coding to open a pop-up.

<input type="button" value="Add" class="button submit" style="width: 80px" onclick="javascript:OpenAttachmentUpload()" />

<script type="text/javascript">

    //User Defined Function to Open Dialog Framework
    function OpenAttachmentUpload() {

        var strPageURL = '<%= ResolveClientUrl("~/Dialogs/AttachUpload.aspx") %>';
        //OpenFixCustomDialog(strPageURL, "Attachment");
        OpenCustomDialog(strPageURL, 350, 200, "Attachment");
        return false;
    }
</script>

here is the script.

function OpenCustomDialog(dialogUrl, dialogWidth, dialogHeight, dialogTitle, dialogAllowMaximize, dialogShowClose) {

    var options = {
        url: dialogUrl,
        allowMaximize: dialogAllowMaximize,
        showClose: dialogShowClose,
        width: dialogWidth,
        height: dialogHeight,
        title: dialogTitle,
        dialogReturnValueCallback: Function.createDelegate(null, CloseCallback3)
    };
    SP.UI.ModalDialog.showModalDialog(options);
}

After opening it, when I close the pop-up (~/Dialogs/AttachUpload.aspx) , I wanna refresh the parent page. How can I do it? I google and see SP.UI.ModalDialog.RefreshPage but still can't find an answer for me. Thanks.

P.s I don't know much about SharePoint.

like image 478
kevin Avatar asked Dec 08 '11 05:12

kevin


1 Answers

You're almost there.

In the option dialogReturnValueCallback you can define a function that will be executed after the dialog was closed. By now you create a delegate pointing to CloseCallback3 but this is not defined in your code.

If you call SP.UI.ModalDialog.RefreshPage in this callback method the page gets refreshed after the dialog was closed with OK.

 var options = 
 {
        url: dialogUrl,
        allowMaximize: dialogAllowMaximize,
        showClose: dialogShowClose,
        width: dialogWidth,
        height: dialogHeight,
        title: dialogTitle,
        dialogReturnValueCallback: function(dialogResult) 
        { 
          SP.UI.ModalDialog.RefreshPage(dialogResult) 
        }
 }

Btw: You use javascript: in the onclick of the button. This is not necessary. this is only required in the href of an a tag

like image 163
Stefan Avatar answered Sep 22 '22 08:09

Stefan