Unable to get property ‘showModalDialog’ of undefined or null reference

Posted on Updated on

the “Unable to get property ‘showModalDialog’ of undefined or null reference” error display because you are not calling the sp.ui.dialog.js

Wrong Way:

SP.UI.ModalDialog.showModalDialog(options);
 

Good Way:

SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options); 
 

Sample

function openYourDialog(tUrl, tTitle) {
	 var options = {
		 url: tUrl,
		 title: tTitle
	 };
	 SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options); 
 }

Calling:

<a href="#" onclick="openYourDialog('MyPage.aspx','Basic;">Show Dialog</a> 
Advertisements

5 thoughts on “Unable to get property ‘showModalDialog’ of undefined or null reference

    Salman Ahmad said:
    October 15, 2014 at 13:07

    Good stuff. However, you forgot to close the bracket in

    Show Dialog

    Dildar Ali said:
    October 27, 2014 at 06:17

    nice helpful

    Muhammad Gouda said:
    June 7, 2015 at 19:03

    Thanks .. it saved my time

    Ahmad Gamal said:
    June 8, 2015 at 07:38

    Thanks so much, very helpful

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s