Home » Blog » SharePoint Modal Dialog does not work under SharePoint 2013

SharePoint Modal Dialog does not work under SharePoint 2013

SharePoint Modal Dialog does not working in SharePoint 2013

When migrating our Solutions2Share License Management Solution from SharePoint 2010 to SharePoint 2013 the SharePoint Modal Dialog did not open.

SharePoint 2010 Example:

   1: function ShowServerInformation() {
   2:         var options = {
   3:             url: '/_admin/Solutions2Share/LicenseManagement/GeneralServerInformation.aspx',
   4:             tite: 'Server Information',
   5:             allowMaximize: false,
   6:             showClose: true,
   7:             width: 430,
   8:             height: 230
   9:         };
  10:
  11:         SP.UI.ModalDialog.showModalDialog(options);
  12:         return false;
  13:     }
Full Microsoft 365 Provisioning

How to fix this problem

Time needed: 3 minutes

How to fix SharePoint Modal Dialog in SharePoint 2013

  1. Remove Java Script reference

    Remove the following Java Script reference:
    <script src=”/_layouts/sp.js” type=”text/javascript”></script>
    <script src=”/_layouts/SP.UI.Dialog.js” type=”text/javascript”></script>

  2. Add URL variable

    Add to the URL variable “?IsDlg=1″

  3. Replace command

    Replace the command SP.UI.ModalDialog.showModalDialog() with the new command SP.SOD.execute(‘sp.ui.dialog.js’, ‘SP.UI.ModalDialog.showModalDialog’, options);

With these small changes your solution will work correctly.

SharePoint 2013 Example:

   1: function ShowServerInformation(featureId) {
   2:       var options = {
   3:           url: '/_admin/Solutions2Share/LicenseManagement/ServerInformation.aspx?featureId=' + featureId + "&IsDlg=1",
   4:           title: 'Server Information',
   5:           allowMaximize: false,
   6:           showClose: true,
   7:           width: 430,
   8:           height: 230
   9:       };
  10:
  11:       SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
  12:
  13:       return false;
  14:   }

Looking for a tool to improve SharePoint collaboration in your organization? Check out our Teams Manager!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Copyright 2021 © Solutions2Share GmbH

Terms and conditions Privacy policy Cookie Policy Imprint

Send this to a friend