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

  • 相关阅读:
    IntelliJ IDEA 14.03 java 中文文本处理中的编码格式设置
    应聘感悟
    STL string分析
    CUDA SDK VolumeRender 分析 (1)
    BSP
    CUDA SDK VolumeRender 分析 (3)
    CUDA SDK VolumeRender 分析 (2)
    Windows软件发布时遇到的一些问题
    Ten Commandments of Egoless Programming (转载)
    复习下光照知识
  • 原文地址:https://www.cnblogs.com/andycai/p/1586743.html
Copyright © 2011-2022 走看看