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

来源:互联网 发布:win10网络图标消失 编辑:程序博客网 时间:2024/05/16 18:35

在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);

原创粉丝点击