现在的位置: 首页 > 综合 > 正文

sharepoint 2010 弹出模式窗口showModalDialog并返回值returnResult方法

2013年12月23日 ⁄ 综合 ⁄ 共 1645字 ⁄ 字号 评论关闭

1。创建一个BasePage.aspx页面。

<asp:ContentID="PageHead"
ContentPlaceHolderID="PlaceHolderAdditionalPageHead"
runat="server">

<script>

    function showDialog() {

        var options = {

            url: "ShowDialogPage.aspx",

            args: 7,

            title: "选择页面",

            dialogReturnValueCallback: dialogCallback

        };

        SP.UI.ModalDialog.showModalDialog(options);

    }

    //接收返回值方法

    function dialogCallback(dialogResult, returnValue) {

        //其中dialogResult=1,代表确定,dialogResult=0,代表关闭

        if (returnValue !=
null
&& dialogResult == 1) {

            alert(returnValue); //弹出窗口

            document.getElementById('<%=ItemID.ClientID%>').value = returnValue;

        }

        return;

    }

</script>

</asp:Content>

 

2。创建一个弹出页面。ShowDialogPage.aspx

<asp:ContentID="PageHead"
ContentPlaceHolderID="PlaceHolderAdditionalPageHead"
runat="server">

<script>

    //返回值方法

    function ReturnPageValue() {

        window.frameElement.commitPopup(document.getElementById('<%=txtValue.ClientID%>').value);

    }

</script>

</asp:Content>

<asp:ContentID="Main"
ContentPlaceHolderID="PlaceHolderMain"
runat="server">

    <inputid="txtValue"
type="text"
runat
="server" />

    <inputid="BtnOK"
type="button"
value
="确定"onclick="ReturnPageValue();"/>

    <inputid="BtnClose"
type="button"
value
="关闭"onclick="window.frameElement.cancelPopUp();"/>

</asp:Content>

<asp:ContentID="PageTitle"
ContentPlaceHolderID="PlaceHolderPageTitle"
runat="server">

应用程序页

</asp:Content>

<asp:ContentID="PageTitleInTitleArea"
ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea"
runat="server"
>

我的应用程序页

</asp:Content>

3。部署到MOSS环境。

点击选择按钮

弹出ShowDialogPage.aspx页面

 在文本框填写“我是返回值”,点击确定。如下图,“我是返回值”,已经返回到文本框。

 

程序下载地址:http://download.csdn.net/detail/cxx2325938/5162960

抱歉!评论已关闭.