您的位置:首页 > 编程语言 > C#

C#在后台注册一个脚本,打开一个子窗口,显示在屏幕中间,关闭子窗体刷新子窗体代码

2011-04-26 16:58 876 查看
在Gridview控件的RowCommand事件里写

if (e.CommandName == "unBd")
{
string id = e.CommandArgument.ToString();
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "click", "var width=Math.round((window.screen.width-380)/2);var height=Math.round((window.screen.height-150)/2);window.open('UnBanding.aspx?id=" + id + "&t=v','unbing','height=150, width=380, top='+height+', left='+width+', toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no');", true);
}

/////////////在子窗体里,完成一些操作后,关闭子窗体,同时刷新父页面,子页面要加上 <base target="_self" />////////////

ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "click", "window.alert('操作成功!');window.opener.location.href=window.opener.location.href;window.close();", true);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐