用ASP.NET怎样响应页面的关闭事件?

 <html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>页面标题</title>

    <script language="javascript" type="text/javascript">

function guanbi()
    {
        document.getElementById("buanbi").click();
    }

    </script>

</head>
<body class="body" onunload="guanbi()">

<input id="buanbi" name="buanbi" runat="server" onserverclick="Button1_ServerClick" type="button"
                        value="button" />

</body>

</html>

 

后台CS代码

    protected void Button1_ServerClick(object sender, EventArgs e)
    {
        执行相关的操作
        //Response.Write("<script>window.parent.opener=null;window.parent.close();</script>");
        //Response.Write("<script>window.location.href='default.aspx';</script>");
        JScript.ExecuteClientScript("window.close();", this.Page);
    }

 

posted @ 2008-11-02 02:03  liangwei389  Views(2172)  Comments(0Edit  收藏  举报