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');");
                    }

    }

  • 相关阅读:
    git merge远程合并
    开发中必知必会的常用Linux命令
    mysql双机双向热备
    入门级实操教程!从概念到部署,全方位了解K8S Ingress!
    linux常用命令,你应该了解的Linux知识
    MFC的静态库.lib、动态库.dll(包含引入库.lib)以及Unicode库示例
    Java 表达式之谜:为什么 index 增加了两次?
    Vavr Option:Java Optional 的另一个选项
    一文详解 Java 的八大基本类型!
    如何找到真正的 public 方法
  • 原文地址:https://www.cnblogs.com/Chinarain/p/3821965.html
Copyright © 2011-2022 走看看