zoukankan      html  css  js  c++  java
  • JS使用showModalDialog返回值

    1、//跳转的超链接

    <a href="javascript:void(0);" onclick="openSub();return false;" class="acss" runat="server"
                id="lnkAddDetail">選擇</a>

    //子页面的返回值带回到父页面的DropDownList_F27中

    <asp:DropDownList runat="server" ID="DropDownList_F27" CssClass="pub_clsInputSelect DropDownListElement FORM6_ID"
                Enabled="true" AutoPostBack="True" Width="155px" OnSelectedIndexChanged="DropDownList_F27_SelectedIndexChanged">
            </asp:DropDownList>

    2、

    <script language="javascript" type="text/javascript">
            //选择人力需求单
            function openSub() {
                var totalRows = $("#<%=GridView_SUB1.ClientID %> tr").length - 1;
                var returnValue = window.showModalDialog('SelectHrForm.aspx?TOTALCOUNT=' + totalRows, '', 'dialogWidth=1000px;dialogHeight=600px');
                var objList = document.getElementById("<%=DropDownList_F27.ClientID%>");
                for (var i = 0; i < objList.options.length; i++) {
                    if (objList.options[i].text == returnValue) {
                        objList.options[i].selected = true;
                    }
                }
                document.getElementById("<%=hdnChange.ClientID%>").click();

            }
        </script>

    3、子页面代码

    RegisterScript(string.Format("window.returnValue = '{0}';window.close()", strHrNeedFormId), true);//保存返回的值,并关闭子页面

    //注册脚本

            public void RegisterScript(string script, bool isAfter)
            {
                if (isAfter)
                    ClientScript.RegisterStartupScript(typeof(System.Web.UI.Page), Guid.NewGuid().ToString(), script, true);
                else
                    ClientScript.RegisterClientScriptBlock(typeof(System.Web.UI.Page), Guid.NewGuid().ToString(), script, true);
            }

    下面讲使用showModalDialog普通跳转,不带返回值

    <asp:GridView ID="grdProcessing_Status"  OnRowCommand="grdProcessing_Status_RowCommand">

           <ItemTemplate>
                               <asp:LinkButton ID="Label2" runat="server" CommandName="Details" CommandArgument='<%# DataBinder.Eval(Container,"DataItem.FORM_NO") %>' Text='<%# DataBinder.Eval(Container, "DataItem.SerialNO")%>'>         
                                 </asp:LinkButton>
             </ItemTemplate>

    protected void grdProcessing_Status_RowCommand(object sender, GridViewCommandEventArgs e)
            {

                    //詳細
                    if (e.CommandName == "Details")
                    {
                        GridViewRow row = ((LinkButton)e.CommandSource).Parent.Parent as GridViewRow;
                        string formNO = e.CommandArgument.ToString();
                        ScriptStartup("window.showModalDialog('../CARRFORM1_View/Main.aspx?FORM_NO=" + formNO + "','','dialogWidth:800px;dialogHeight:700px;center:yes;help:no;status:no;resizable:yes');");
                    }

    }

  • 相关阅读:
    python3 访问 rabbitmq 示例
    centos7 GNOME 安装微信客户端
    使用 rm -rf 删除了工程目录,然后从 pycharm 中找了回来
    主动做事,做一个靠谱的人
    Go net/http 发送常见的 http 请求
    学会感激,才能长大
    Go context 介绍和使用
    xargs 命令
    Docker 镜像 && 容器的基本操作
    CentOS && Ubuntu 环境下 Docker 的安装配置
  • 原文地址:https://www.cnblogs.com/Chinarain/p/3821965.html
Copyright © 2011-2022 走看看