Skip to content Skip to sidebar Skip to footer

Commonmodaldialogclose(sp.ui.dialogresult.ok, Somevalue) Throws Error

In SharePoint 2010 I have a visual web part that uses SP.UI.ModalDialog.showModalDialog The dialog shows up fine but when I try to close the dialog using SP.UI.ModalDialog.commonM

Solution 1:

A quick/hacky workaround would be to use 1 which stands for SP.UI.DialogResult.OK

Thanks, I was able to get this to work using numbers instead of SP.UI.DialogResult.OK.

For example...

SP.UI.ModalDialog.commonModalDialogClose(0,'Canceled the dialog.'); is like using SP.UI.DialogResult.cancel

SP.UI.ModalDialog.commonModalDialogClose(1,'Yay Success!'); is like using SP.UI.DialogResult.OK

SP.UI.ModalDialog.commonModalDialogClose(-1,'Uh oh... Error'); is like using SP.UI.DialogResult.invalid

Solution 2:

You need to include the SharePoint JS file SP.UI.Dialog.js on your "dialog page".

<SharePoint:ScriptLinkName="SP.UI.Dialog.js"runat="server" />

or

<scriptsrc="/_layouts/SP.UI.Dialog.js"type="text/javascript"></script>

A quick/hacky workaround would be to use 1 which stands for SP.UI.DialogResult.OK.

Post a Comment for "Commonmodaldialogclose(sp.ui.dialogresult.ok, Somevalue) Throws Error"