ASP.NET弹出模态对话框
主页面 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
}
}
{
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>
<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>
<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();
}
}
{
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>");
Response.Write("window.close()");
Response.Write("</script>");
参考:http://www.cnblogs.com/penboy/archive/2005/11/22/121773.html
作者: XuGang 网名:钢钢 |
出处: http://xugang.cnblogs.com |
声明: 本文版权归作者和博客园共有。转载时必须保留此段声明,且在文章页面明显位置给出原文连接地址! |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架