背景:
阅读新闻

SPS中弹窗传值

  作者: 今日评论: [字体: ]

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>

<%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>

<%@ Import Namespace="Microsoft.SharePoint" %>

<%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Register TagPrefix="MySharePoint" Namespace="SharePointProject2" Assembly="$SharePoint.Project.AssemblyFullName$" %>

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CaseAdd.ascx.cs" Inherits="SharePointProject2.CONTROLTEMPLATES.CaseAdd" %>



<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>



<style type="text/css">

    td {

        min-height: 40px;

    }

</style>


<script>

    function openDialogAndReceiveData(tUrl, tTitle)

    {

        var options = {

            url: tUrl,

            title: tTitle,

            dialogReturnValueCallback: onPopUpCloseCallBackWithData

        };

        SP.UI.ModalDialog.showModalDialog(options);

    }


    function onPopUpCloseCallBackWithData(result, returnValue)

    {

        if (result == SP.UI.DialogResult.OK)

        {

            SP.UI.Status.removeAllStatus(true);

            var sId = SP.UI.Status.addStatus("Data successfully populated to text boxes from Pop-up");

            SP.UI.Status.setStatusPriColor(sId, 'green');

            document.getElementById('<%= txtLawyerName1.ClientID %>').value = returnValue[0];

            document.getElementById('<%= txtCountry1.ClientID %>').value = returnValue[1];

            document.getElementById('<%= txtCity1.ClientID %>').value = returnValue[2];

        } else if (result == SP.UI.DialogResult.cancel)

        {

            SP.UI.Status.removeAllStatus(true);

            var sId = SP.UI.Status.addStatus("You have cancelled the Operation !!!");

            SP.UI.Status.setStatusPriColor(sId, 'yellow');

        }

    }


    //put the src bellow into popup page

    function closePopupAndPassData()

    {

        var popData = [];

        popData[0] = document.getElementById('<%= txtLawyerName1.ClientID %>').value;

        popData[1] = document.getElementById('<%= txtCountry1.ClientID %>').value;

        SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK, popData);

    }


    function openLawyerSel()

    {

        openDialogAndReceiveData("/_layouts/15/SelLawyer.aspx", "选择律师");

    }


</script>




<div>

    <input id="txtLawyerName1" type="text" value="txtLawyerName1" runat="server" />

</div>

<div>

    <input id="txtCountry1" type="text" value="txtCountry1" runat="server" />

</div>

<div>

    <input id="txtCity1" type="text" value="txtCity1" runat="server" />

</div>

<div>

    <input id="btnClientOk2" type="button" value="打开选择律师页面" onclick="openLawyerSel()" />

</div>





弹窗页面

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SelLawyer.aspx.cs" Inherits="SharePointProject2.Layouts.SelLawyer" DynamicMasterPageFile="~masterurl/default.master" %>

<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">


    <style type="text/css">
        td {
            min-height: 40px;
        }
    </style>


<%--  
    <script type="text/javascript" src="/_layouts/15/SP.JS"></script>
    <script type="text/javascript" src="/_layouts/15/SP.Core.JS"></script>
    <script type="text/javascript" src="/_layouts/SP.JS"></script>
    <script type="text/javascript" src="/_layouts/SP.Core.JS"></script>
  <SharePoint:ScriptLink Name="SP.UI.Dialog.js" runat="server" />--%>



    <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="/_layouts/SP.UI.Dialog.js"></script>


    <script type="text/javascript">
        function closePopupAndPassData()
        {
            var popData = [];
            popData[0] = document.getElementById('<%= txtLawyerName1.ClientID %>').value;
            popData[1] = document.getElementById('<%= txtCountry1.ClientID %>').value;
            popData[2] = document.getElementById('<%= txtCity1.ClientID %>').value;
            SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK, popData);
        }
    </script>

</asp:Content>

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <div>
        <input id="btnClientOk2" type="button" value="Client Side OK and pass Value to Base Page" onclick="closePopupAndPassData()" />
    </div>
    <div>
        <input id="txtLawyerName1" type="text" value="Lawyer Name1" runat="server" />
    </div>
    <div>
        <input id="txtCountry1" type="text" value="Lawyer Country1" runat="server" />
    </div>
    <div>
        <input id="txtCity1" type="text" value="Lawyer City1" runat="server" />
    </div>
</asp:Content>

<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
    应用程序页
</asp:Content>

<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server">
    我的应用程序页
</asp:Content>

来源:
录入日期:[2017/12/23 2:12:00]
收藏 推荐 打印 | 录入:mikebai | 阅读:
文章评论      
正在加载评论列表...
评论表单加载中...