最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - commonModalDialogClose(SP.UI.DialogResult.OK, someValue) throws error - Stack Overflow

programmeradmin2浏览0评论

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.ModalDialogmonModalDialogClose(SP.UI.DialogResult.OK, someValue)

I get an error that says

Unable to get value of the property 'OK': object is null or undefined

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.commonModalDialogClose(SP.UI.DialogResult.OK, someValue)

I get an error that says

Unable to get value of the property 'OK': object is null or undefined

Share Improve this question asked Jan 17, 2012 at 20:35 PaulPaul 1,9472 gold badges21 silver badges29 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 14

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

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

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

or

<script src="/_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.

发布评论

评论列表(0)

  1. 暂无评论