zoukankan      html  css  js  c++  java
  • 模态对话框页面关闭父页面刷新提交查询

    项目中有用到父页面查询出记录后,通过模态对话框打开编辑,编辑成功关闭模态对话框后再次提交查询动作.主要思路是当子页面返回成功时,通过一个隐藏的Button服务器控件来再次查询. 隐藏Button后台事件中与正常查询后台保持一致.通过回调函数

    __doPostBack 来触发隐藏Button.

    做法如下:

    1.父页面:

    <%@ Page > 中加上enableEventValidation="false"  //是因为用了__doPostBack('ctl00$MainContentPlaceHolder$btnRefurbish','abc') 

    <script type="text/javascript" language="javascript" >
      function OpenEdit(frmWin,width,height) 
      {       
       var me;  
       me = window; 
       var returnVal = window.showModalDialog(frmWin,me,'dialogWidth='+width +'px;dialogHeight='+height+'px;help:no;status:no;') 
       if (returnVal=="True")                 //接收模态对话框页面参数
            {   
               __doPostBack('ctl00$MainContentPlaceHolder$btnRefurbish','abc')          //通過隱藏button重新查询

            } 

      }
    </script>

                            <td><asp:Button ID ="btnSearch" runat="server" Text ="Search"  CssClass="Button" OnClick="btnSearch_Click" /></td> // 正常查询
                            <td><asp:Button id="btnRefurbish"  runat="server" Text="Button"  Visible="false" OnClick="btnRefurbish_Click"/></td> // 隐藏查询

    模态对话框子页面:

    后台成功后 关闭并传参

                        Response.Write("<script language='javascript'>");
                        Response.Write("window.returnValue='True';window.close()");
                        Response.Write("</script>");

    这里要注意的是如果父页面中必须有AutoPost=True的控件.否则不能直接使用__doPostBack()方法.

    必须手动增加:

    function __doPostBack(eventTarget, eventArgument) 
      {
          var theform;
          if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) 
         {
              theform = document.Form1;
         }
         else 
         {
             theform = document.forms["Form1"];
         }
         theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
         theform.__EVENTARGUMENT.value = eventArgument;
         theform.submit();
    }
    还要 要增加 以下两个隐藏字段 

         <input type="hidden" name="__EVENTTARGET"> 
        <input type="hidden" name="__EVENTARGUMENT">

    参考:http://www.php100.com/html/webkaifa/javascript/2009/0418/1509.html

  • 相关阅读:
    js常用函数(不断添加中。。。)
    【转】linux常用命令全集
    【转】VC++消息钩子编程
    beyond compare ftp 文件夹同步
    【转】notepad++ 应用学习 -- 列模式,十六进制模式
    网页嵌入视频播放器
    java中 正则表达式的使用
    【转】正则表达式30分钟入门教程
    【转】深入研究java.lang.Runtime类
    js 中map的几种实现方式
  • 原文地址:https://www.cnblogs.com/andycai/p/1586743.html
Copyright © 2011-2022 走看看