• 模态对话框页面关闭父页面刷新提交查询


    项目中有用到父页面查询出记录后,通过模态对话框打开编辑,编辑成功关闭模态对话框后再次提交查询动作.主要思路是当子页面返回成功时,通过一个隐藏的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

  • 相关阅读:
    python+selenium之中类/函数/模块的简单介绍和方法调用
    python之类
    Python+Selenium之断言对应的元素是否获取以及基础知识回顾
    Python+Selenium之摘取网页上全部邮箱
    C# 事件
    IConfigurationSectionHandler 接口
    ReaderWriterLockSlim 类
    log4net 按照日期备份日志
    Redis .net 客户端 分布式锁
    SQL Server Compact/SQLite Toolbox
  • 原文地址:https://www.cnblogs.com/andycai/p/1586743.html
Copyright © 2020-2023  润新知