sharepoint 2016 弹出新窗口并返回值的方法
2016-10-18 16:07
387 查看
1.创建一个ModalDialogTest的可视化webpart,代码如下:<script> function OpenModalDialog(title, width, height) { var options = SP.UI.$create_DialogOptions(); var options = { title: title, width: width, height: height, url: "/sitepages/test2.aspx" }; options.dialogReturnValueCallback =Function.createDelegate(null, CloseCallback); SP.UI.ModalDialog.showModalDialog(options); SP.UI.ModalDialog.showModalDialog(options); } // Dialog callback function CloseCallback(result, retVal) { if (result == SP.UI.DialogResult.OK) { // Run OK Code // To be consistent with the below... document.getElementById('<%=CurrentText.ClientID%>').value = retVal[0]; //close ModalDialog. SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel, 'Cancelled clicked'); // Note that I use this.dataArray to allow theobject to be accessed throughout the code } if (result == SP.UI.DialogResult.cancel) { // Run Cancel Code SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel, 'Cancelled clicked'); } } </script>
<input id="CurrentText" runat="server" type="text" /><input id="BtnOpenModalDialog" type="button" value="打开新窗口" onclick="OpenModalDialog('弹窗新窗口',600', '600');" />
2.在sharepoint创建一个web部件页test1.aspx,存放在网站页面的文档库中,存放的路径:/sitepages/test1.aspx,并且将ModalDialogTest添加到test1.aspx页面。
3.创建一个NewDialog的可视化webpart,代码如下:
<script type="text/javascript"> function BtnCloseFunc() { SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel, 'Cancelled clicked'); } function BtnCloseAndReturnValueFunc() { var returnValue = []; // array returnValue[0] = document.getElementById('<%=NewDialogText.ClientID%>').value; SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK,returnValue); } </script> <input id="NewDialogText" type="text" runat="server" /> <input id="BtnCloseAndReturnValue" type="button" value="关闭并返回值" onclick="BtnCloseAndReturnValueFunc();" />
<input id="BtnClose" type="button" value="关闭" onclick="BtnCloseFunc();" />
<input id="CurrentText" runat="server" type="text" /><input id="BtnOpenModalDialog" type="button" value="打开新窗口" onclick="OpenModalDialog('弹窗新窗口',600', '600');" />
2.在sharepoint创建一个web部件页test1.aspx,存放在网站页面的文档库中,存放的路径:/sitepages/test1.aspx,并且将ModalDialogTest添加到test1.aspx页面。
3.创建一个NewDialog的可视化webpart,代码如下:
<script type="text/javascript"> function BtnCloseFunc() { SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel, 'Cancelled clicked'); } function BtnCloseAndReturnValueFunc() { var returnValue = []; // array returnValue[0] = document.getElementById('<%=NewDialogText.ClientID%>').value; SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK,returnValue); } </script> <input id="NewDialogText" type="text" runat="server" /> <input id="BtnCloseAndReturnValue" type="button" value="关闭并返回值" onclick="BtnCloseAndReturnValueFunc();" />
<input id="BtnClose" type="button" value="关闭" onclick="BtnCloseFunc();" />
相关文章推荐
- sharepoint 2010 弹出模式窗口showModalDialog并返回值returnResult方法
- sharepoint 2010 弹出模式窗口showModalDialog并返回值returnResult方法
- sharepoint 2010 弹出模式窗口showModalDialog并返回值returnResult方法
- 弹出窗口并返回值,Event/window.Event属性和方法和returnValue的用法
- 关于弹出窗口操作父窗口select列表框的解决方法
- ]如何点击按钮弹出新窗口,输入数据后返回并刷新页面?(C#代码)
- 如何点击按钮弹出新窗口,输入数据后返回并刷新页面?
- 自适应图片大小的弹出窗口(3 中方法)
- 新弹出窗口的几种方法
- 弹出窗口全攻略,代码,方法
- 如何点击按钮弹出新窗口,输入数据后返回并刷新页面?
- ASP.NET DATAGRID中如何点击整列或模板列后弹出窗口并选中新窗口数据将值返回给模板列中的文本框
- 自适应图片大小的弹出窗口(3 中方法)
- 如何点击按钮弹出新窗口,输入数据后返回并刷新页面?
- 如何点击按钮弹出新窗口,输入数据后返回并刷新页面?
- HTML中加弹出窗口方法
- 自适应图片大小的弹出窗口(方法2)(转)
- 如何点击按钮弹出新窗口,输入数据后返回并刷新页面?
- [ASP.NET]如何点击按钮弹出新窗口,输入数据后返回并刷新页面?(C#代码)
- 如何点击按钮弹出新窗口,输入数据后返回并刷新页面?