I am trying to create a modal that generates off of a link. When the link is clicked, the modal pops-up but I get the error, "An unexpected error has occurred". When I dive deeper, I find out that SharePoint has appended '?IsDlg=1' to the URL, which causes it to error out. How can I fix this issue? Code below:

<script type="text/javascript">
//User Defined Function to Open Dialog Framework
function OpenDialog(strPageURL)

 var dialogOptions = SP.UI.$create_DialogOptions();
 dialogOptions.url = strPageURL;// URL of the Page
 dialogOptions.title = 'Welcome to SharePoint'
 dialogOptions.allowMaximize= true
 dialogOptions.width = 950; // Width of the Dialog
 dialogOptions.height = 500; // Height of the Dialog
 dialogOptions.dialogReturnValueCallback = Function.createDelegate( null, 
 CloseCallback); // Function to capture dialog closed event
 SP.UI.ModalDialog.showModalDialog(dialogOptions); // Open the Dialog
 return false;

function CloseCallback(strReturnValue, target)
 if (strReturnValue === SP.UI.DialogResult.OK) // Perform action on Ok.
alert("User clicked Ok!");
if (strReturnValue === SP.UI.DialogResult.cancel) // Perform action on 
alert( "User clicked Cancel!");



<a onclick="OpenDialog('../SitePages/vueCarausel.aspx');">open dialog</a>​


2 Answers 2


'?IsDlg=1' is how SharePoint knows to display a page as a dialog box. With this in the query string, the master page hides all non-form data such as the site icon, title, toplink bar and Quick Launch. To see the impact of '?IsDlg=1', go to a list or library page and note the normal page layout. Append '?IsDlg=1' to the URL and note the changes.

So, I don't think '?IsDlg=1' is the cause of your error. It is what generates the standard SharePoint dialog box.


Since it's a Modal Dialog, I believe SharePoint appends "?IsDlg=1" to the end of the URL to strip out the layout content. I've seen that error appear when we add the "?IsDlg=1" to the end of any SitePage.

Is it possible to have a page created that is using a page layout, and initiate it from that page? Generally, these are publishing pages, web part pages, or forms (NewForm, EditForm). Using Mike's suggestion, would be a good idea to try appending the string to the page you have generated or navigate a user to, in order to ensure that works.


Further info on the IsDlg=1 error, with regards to page errors (Look for "Jashion's" reply https://answers.microsoft.com/en-us/msoffice/forum/msoffice_sharepoint-mso_winother-mso_o365b/using-isdlg-with-pages/286f324c-3054-4d7c-8ae9-d928fd2e1b17


Additional info on how to use "SP.UI.ModalDialog" to call an HTML page, in case it's not practical to use a Web Part page. It may help, but I have not tried the code on this link:

How to use SP.UI.ModalDialog on plain old HTML page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.