Jai Prakash
how to update a database value while closing the asp.net page? (unload event is nt working)
By Jai Prakash in ASP.NET on Sep 22 2008
  • sunil kumar
    Sep, 2008 26

    hi you can try this code: // JScript File var myclose = false; var objLogout = null; function ConfirmClose() { if (event.clientY < 0) { event.returnValue = 'Are you sure to close the browser?'; setTimeout('myclose=false',100); myclose=true; } } function LogoutUser() { if (myclose==true) { Logout(); } } function Logout() { try { objLogout = new XMLHttpRequest(); } catch(ex) { try { objLogout=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { objLogout=new ActiveXObject("Microsoft.XMLHTTP"); } catch(e1) { objLogout=null; } } } objLogout.onreadystatechange=Process_Response_Logout; objLogout.open("GET","BrowserCloseLogout.aspx",true); objLogout.send(null); return false; } function Process_Response_Logout() { if(objLogout.readyState == 4) { if(objLogout.status == 200) { } } }

    • 0
  • Bechir Bejaoui
    Sep, 2008 25

    Implement the IDisposable interface class ClassName:IDisposable { ...... IDisposable.Dispose() { yourConnection.Close(); } } or you can use string Connectionstring = ""; //TO DO precise your connection string between cotes using(xxxConnection cn = new Connection(ConnectionString)) { //TO DO :Put your code here } Once the connection is not used it will be closed automatically

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS