zoukankan      html  css  js  c++  java
  • 关于showModalDialog 的常见问题

    在我们的实际开发中,经常会用到showModalDialog 模态窗体,对于其中的问题有时候真是让人头痛,在此我写一点自己在开发中遇到的问题以及解决办法。

    一、刷新问题
     第一种情况是:模态窗体的父窗体不刷新问题,就是在关闭模态窗口后,父窗体不刷新。
                   解决方法:在你的弹出模态窗体的JavaScript后面写上window.location.reload();

     第二种情况是:有时候不想让父窗体刷新,也就是在关闭模态窗口后,让父窗体不刷新
                   解决方法:在你的弹出模态窗体的JavaScript后面写上return false;
    二、关闭问题
    关闭方法:使用JavaScript
    window.opener=null;self.close();

    三、传递对象
       

     1 protected void btnOK_Click(object sender, EventArgs e)
     2     {
     3         System.Text.StringBuilder sb = new System.Text.StringBuilder();
     4         sb.Append("<script language=\"javascript\">");
     5         string strReturnText = string.Empty;
     6         string strReturnValue = string.Empty;
     7         if (Request.Form["rbtnSelect"!= null)
     8         {
     9             strReturnText = Request.Form["rbtnSelect"].ToString();
    10             strReturnValue = Request.Form["rbtnSelect"].ToString();
    11            // Response.Write(strReturnText);
    12         }
    13         if (rdo_NewLocation.Checked == true)
    14         {
    15            // strReturnText = Request.Form["rbtnSelect"].ToString();
    16            // strReturnValue = Request.Form["rbtnSelect"].ToString();
    17 
    18             sb.Append(" var   ret   =   new   Object();");
    19             sb.Append(" ret.txt_BuildingName   =   '" + txt_BuildingName.Text + "';  ");
    20             sb.Append(" ret.txt_Unit   =   '" + txt_Unit.Text + "';  ");
    21             sb.Append(" ret.txt_Floor   =   '" + txt_Floor.Text + "';  ");
    22             sb.Append(" ret.txt_StreetNo   =   '" + txt_StreetNo.Text + "';  ");
    23             sb.Append(" ret.txt_Street   =   '" + txt_Street.Text + "';  ");
    24             sb.Append(" ret.txt_District   =   '" + txt_District.Text + "';  ");
    25             sb.Append(" ret.txt_City   =   '" + txt_City.Text + "';  ");
    26             sb.Append(" ret.txt_Country   =   '" + txt_Country.Text + "';  ");
    27            
    28         }
    29         
    30        // sb.Append("window.returnValue='" + strReturnText + "|" + strReturnValue + "';");
    31         sb.Append("window.returnValue=ret;");
    32         sb.Append("window.close();");
    33         sb.Append("</script>");
    34         Response.Write(sb.ToString());
    35     }
    36 父页面接收
     
    <script language="JavaScript" type="text/javascript">
           
       
    function RelocationSelect()
      
    {
       
    var   ret   =   window.showModalDialog("../Common/RelocationSelection.aspx",'','dialogWidth:630px;   dialogHeight:300px;');   
      
    if(ret   !=   undefined)
      
    {   
      
      document.getElementById(
    "txt_BuildingName").value=  ret.txt_BuildingName;
      document.getElementById(
    "txt_Unit").value=  ret.txt_Unit;
      document.getElementById(
    "txt_Floor").value=  ret.txt_Floor;
      document.getElementById(
    "txt_StreetNo").value=  ret.txt_StreetNo;
      document.getElementById(
    "txt_Street").value=  ret.txt_Street;
      document.getElementById(
    "txt_District").value=  ret.txt_District;
      document.getElementById(
    "txt_City").value=  ret.txt_City;
      document.getElementById(
    "txt_Country").value=  ret.txt_Country;
             
      }

      
    return false;
      }

           
    </script>
  • 相关阅读:
    php 创建多级文件夹
    php 格式化文件大小
    php 微信授权登录
    获取单据编号 不重复 骚
    js获取数组中的最后一个
    php截取
    循序栈
    链表
    顺序表
    halcon学习之阈值算子threshold operators
  • 原文地址:https://www.cnblogs.com/panzhilei/p/751599.html
Copyright © 2011-2022 走看看