关于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      }
None.gif 36  父页面接收
None.gif 
< script language = " JavaScript "  type = " text/javascript " >
None.gif       
None.gif   
function  RelocationSelect()
ExpandedBlockStart.gifContractedBlock.gif  
dot.gif {
InBlock.gif   
var   ret   =   window.showModalDialog("../Common/RelocationSelection.aspx",'','dialogWidth:630px;   dialogHeight:300px;');   
InBlock.gif  
if(ret   !=   undefined)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{   
InBlock.gif  
InBlock.gif  document.getElementById(
"txt_BuildingName").value=  ret.txt_BuildingName;
InBlock.gif  document.getElementById(
"txt_Unit").value=  ret.txt_Unit;
InBlock.gif  document.getElementById(
"txt_Floor").value=  ret.txt_Floor;
InBlock.gif  document.getElementById(
"txt_StreetNo").value=  ret.txt_StreetNo;
InBlock.gif  document.getElementById(
"txt_Street").value=  ret.txt_Street;
InBlock.gif  document.getElementById(
"txt_District").value=  ret.txt_District;
InBlock.gif  document.getElementById(
"txt_City").value=  ret.txt_City;
InBlock.gif  document.getElementById(
"txt_Country").value=  ret.txt_Country;
InBlock.gif         
ExpandedSubBlockEnd.gif  }

InBlock.gif  
return false;
ExpandedBlockEnd.gif  }

None.gif       
</ script >

转载于:https://www.cnblogs.com/panzhilei/archive/2007/05/18/751599.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值