怎样能在页面关闭时执行修改数据库的操作!

解决方案 »

  1.   

    Global.cs
    protected void Application_EndRequest(Object sender, EventArgs e)
    {}要么在<body onbeforeunload="form1.submit()">
      

  2.   

    使用:〈body onbeforeunload="closeIt();">
    function closeIt()
    {
    if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey)
    {
    //window.event.returnValue="确定要退出本页吗?";
    alert('我要退出啦!')
    //document.frames.exitframes.location.reload("exit.aspx?id=2");
    document.frames.exitframes.location.href="exit.aspx?id=2";
    }
    else
    {
    return false;
    }
    }exit.asx你可以放到 一个隐藏 iframe里,大多网站都 这样。
    exit.aspx:
    Sessin.Remoll() or Session["dd"].clea();http://community.csdn.net/Expert/topic/3391/3391901.xml?temp=.8536188
    类似一样的操作
    http://community.csdn.net/Expert/topic/3404/3404491.xml?temp=.2965662