例如:点击父窗口中按钮-〉打开模式对话框-〉输入数据-〉处理数据-〉关闭对话框刷新父窗口

1、在父窗口添加打开模式对话框相关script代码
<script language=javascript>
 
function OpenEditWin(frmWin,width,height) 
    
{       
     
var me; 
     
// 把父页面窗口对象当作参数传递到对话框中,以便对话框操纵父页自动刷新。 
     me = window; 
     
// 显示对话框。 
     var dialog1= window.showModalDialog(frmWin,me,'dialogWidth='+width +'px;dialogHeight='+height+'px;help:no;status:no') 
    }
  
</script>

2、为打开按纽添加事件(可以用url+?传递参数,还可以用OpenEditWin的第二个参数)
protected void Page_Load(object sender, EventArgs e)
 
{
 Button1.Attributes.Add(
"onclick", "javascript:OpenEditWin('selectproperty.aspx?CID=22',500,400)");
 }


*3、对话框页面中一定要加<BASE target=_self>(为了解决对话框提交打开新窗口或者没反应的问题)
为了每次刷新,最好再设置一下不要缓存
<head id="Head1" runat="server">
    
<title>添加记录</title>
    
<BASE target=_self>
         <META HTTP-EQUIV="pragma" CONTENT="no-cache">
</head>

4、为模态对话框添加处理事件,可以把数据更新放到模态页面实现。
5、提交后关闭对话框
Response.Write("<script>window.close()</script>");
 
posted on 2006-11-08 10:44  石叶柳  阅读(1581)  评论(0)    收藏  举报