ASP.NET GridView中鏈結打開模式窗口,當模式窗口關閉時,刷新父頁.
2009-03-27 16:44
309 查看
ASP.NET打開模式窗口,當模式窗口關閉時,刷新父頁.
1.使用Javascript: showModelessDialog打開模式窗口
JS代碼:
function showDialog(url, width, height)
{
showModelessDialog(url, window, 'dialogWidth:' + width + 'px;dialogHeight:' + height + 'px;center:yes;status:no;scroll:yes;help:no');
}
2.在GridView RowDataBound事件添加Link代碼
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
ID = e.Row.Cells[1].Text.ToString().Replace(" ", "").Trim();
if (ID.Length > 0)
{
//添加DT以免緩存影響
string JS = "View.aspx?ID=" + ID + "&DT=" + DateTime.Now.ToString("yyyyMMddHHmmss");
e.Row.Cells[2].Text = "<a href=/"javascript:/" onclick=/"javascript:showDialog('" + JS + "',800,590);/">I</a>";
e.Row.Cells[2].ToolTip = "Open By ID";
}
}
}
3.在模式窗口Head中添加清除緩存代碼
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<base target="_self" />
4.Body添加關閉模式窗口時執行JS代碼,執行父頁Button事件
body style="margin: 0px" onunload="ref();"
function ref()
{
if(window.dialogArguments != null)
{
//window.dialogArguments.location.reload(true);
//dialogArguments.location.replace(dialogArguments.location);
dialogArguments.document.getElementById("btnQuery").click();
//window.close();
}
}
5.父頁Button click事件
protected void btnQuery_Click(object sender, EventArgs e)
{
try
{
Bind();
}
catch (Exception ex)
{
}
}
1.使用Javascript: showModelessDialog打開模式窗口
JS代碼:
function showDialog(url, width, height)
{
showModelessDialog(url, window, 'dialogWidth:' + width + 'px;dialogHeight:' + height + 'px;center:yes;status:no;scroll:yes;help:no');
}
2.在GridView RowDataBound事件添加Link代碼
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
ID = e.Row.Cells[1].Text.ToString().Replace(" ", "").Trim();
if (ID.Length > 0)
{
//添加DT以免緩存影響
string JS = "View.aspx?ID=" + ID + "&DT=" + DateTime.Now.ToString("yyyyMMddHHmmss");
e.Row.Cells[2].Text = "<a href=/"javascript:/" onclick=/"javascript:showDialog('" + JS + "',800,590);/">I</a>";
e.Row.Cells[2].ToolTip = "Open By ID";
}
}
}
3.在模式窗口Head中添加清除緩存代碼
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<base target="_self" />
4.Body添加關閉模式窗口時執行JS代碼,執行父頁Button事件
body style="margin: 0px" onunload="ref();"
function ref()
{
if(window.dialogArguments != null)
{
//window.dialogArguments.location.reload(true);
//dialogArguments.location.replace(dialogArguments.location);
dialogArguments.document.getElementById("btnQuery").click();
//window.close();
}
}
5.父頁Button click事件
protected void btnQuery_Click(object sender, EventArgs e)
{
try
{
Bind();
}
catch (Exception ex)
{
}
}
相关文章推荐
- asp.net 下 使用 showModalDialog 模式窗口
- asp.net模式窗口刷新解决方案
- 在ASP.NET中,如何实现点击按钮弹出新窗口.刷新父窗口
- asp.net 下 使用 showModalDialog 模式窗口 (记录)
- (转载)asp.net 下 使用 showModalDialog 模式窗口
- ASP.NET 清除模式窗口数据缓存
- asp.net中关闭模式窗口时又弹出一新的窗口
- ASP.NET 模式窗口中调用后台代码
- ASP.NET如何输出刷新父窗口脚本语句
- asp.net中 弹出新窗口,提交后,关闭该弹出窗口,刷新父页面
- asp.net关于模式窗口刷新问题
- (转载)asp.net 下 使用 showModalDialog 模式窗口
- Asp.net弹出新窗口,在gridview 获取值并返回值
- ASP.NET 清除模式窗口数据缓存的操作方式
- asp.net子窗口关闭局部刷新父窗口
- asp.net gridview中给删除按钮加confirm窗口
- ASP.NET GridView双击行弹出窗口
- asp.net 下 使用 showModalDialog 模式窗口 (记录)
- asp.net弹出模式窗口 2个例子演示+教程