主页面 PageBase.aspx.cs 中的代码

protected void Page_Load(object sender, EventArgs e)

  
if (!this.IsPostBack)
  {
    
//addBtn.Attributes.Add("onclick", "javascript:ShowModalDialog('OvertimeDlog.aspx','395px','250px')");
    
//delBtn.Attributes.Add("onclick", "javascript:ShowModalDialog('OvertimeDlog.aspx','395px','250px')");
    this.addBtn.Attributes.Add("onclick""javascript:OpenOvertimeDlog('add',540,400)");   // 增加 Button
    this.updateBtn.Attributes.Add("onclick""javascript:OpenOvertimeDlog('up',540,400)"); // 修改 Button
  }
}


主页面 PageBase.aspx 中的代码

<head runat="server">
  
<title>无标题页</title>
  
<script type ="text/javascript" language = "javascript">
   
function OpenOvertimeDlog(frmWin,width,height) 
   {       
     
var me; 
     
var action;
     action 
= frmWin;
     
// 把父页面窗口对象当作参数传递到对话框中,以便对话框操纵父页自动刷新。 
     me = "OvertimeDlog.aspx?action="+action+""
     
// 显示对话框。
     window.showModalDialog(me,null,'dialogWidth='+width +'px;dialogHeight='+height+'px;help:no;status:no'
   } 
  
</script>
</head>


弹出对话框页面 OpenDlog.aspx 中的代码

<head runat="server">
    
<title>无标题页</title>
    
<!-- 防止重新打开页面形式的对话框 -->
    
<base target="_self" /> 
</head>


弹出对话框页面 OpenDlog.aspx.cs 中的代码

OpenDlog.aspx.cs
{
    
protected void Page_Load(object sender, EventArgs e)
    {
        
//获得传递的 action 的值;
        string getRequest = Request["action"].ToString();
    }
}

对话框页面 OpenDlog.aspx.cs 关闭后,执行更新操作(在对话框的关闭事件中加入):

  Response.Write("<script language='javascript'>"); 
  Response.Write(
"window.close()"); 
  Response.Write(
"</script>"); 

 
参考:http://www.cnblogs.com/penboy/archive/2005/11/22/121773.html

 

作者: XuGang   网名:钢钢
出处: http://xugang.cnblogs.com
声明: 本文版权归作者和博客园共有。转载时必须保留此段声明,且在文章页面明显位置给出原文连接地址!
posted on 2013-06-25 23:17  網絡蛀蟲  阅读(261)  评论(0编辑  收藏  举报