Opening a Modal dialog box in SharePoint

It is a good practice to display a “loading” page like below opening a Modal dialog from a web part or an Application page.

clip_image002

Recently I had a requirement to open the out of the box “Manage Access Requests” page from my web part for which I wrote the below code to open the “Manage Access Requests” on a button click:

var options =
{
  url: URL + "/_layouts/setrqacc.aspx?type=web&Source=" + URL + "&IsDlg=1",
  title: "Manage Access Requests",
  height: 500px,
  width: 300px,
  dialogReturnValueCallback: onDialogClose
};

SP.UI.ModalDialog.showModalDialog(options);

The modal dialog opened without any problem but the “loading” page in the above image did not display before opening the modal dialog which looked quite absurd as the modal dialog took some time to open.

After googling I found a solution in Stackoverflow that removing the height and width property in the above code would show the pre-loading page before opening the modal dialog page. To my surprise it did solve the issue. The pre-loading page got displayed before the Modal dialog opened.

Advertisements