前台asp按钮(此处我是一个ImageButton)
<asp:ImageButton ID="ImageButton4" ImageUrl="~/images/btndel2.png" runat="server" Style="width:20px;height:20px;" OnClick="ImageButton4_Click"/>
后台关闭Web窗口
protected void ImageButton4_Click1(object sender, ImageClickEventArgs e)
{
ClientScript.RegisterStartupScript(Page.GetType(), "", "<script language=javascript>window.opener=null;window.open('','_self');window.close();</script>");
}
本文介绍了一种在ASP.NET中使用ImageButton触发关闭当前Web窗口的方法。通过在ImageButton的点击事件中注册StartupScript,利用JavaScript实现了关闭窗口的功能。这种方法适用于需要在用户操作后自动关闭窗口的场景。
934

被折叠的 条评论
为什么被折叠?



