Click here to Skip to main content
15,899,754 members
Home / Discussions / ASP.NET
   

ASP.NET

 
Questionhow to embeded gtalk in my application? Pin
pramodgorityala8-Jun-10 20:42
pramodgorityala8-Jun-10 20:42 
AnswerRe: how to embeded gtalk in my application? Pin
Arun Jacob8-Jun-10 20:46
Arun Jacob8-Jun-10 20:46 
GeneralRe: how to embeded gtalk in my application? Pin
pramodgorityala8-Jun-10 21:09
pramodgorityala8-Jun-10 21:09 
QuestionMessage Removed Pin
8-Jun-10 20:41
Chan Myae Naing8-Jun-10 20:41 
AnswerRe: Saving Files to a Database Pin
Arun Jacob8-Jun-10 20:47
Arun Jacob8-Jun-10 20:47 
QuestionHandle Browser close event by pressing [X] Pin
koolprasad20038-Jun-10 18:40
professionalkoolprasad20038-Jun-10 18:40 
AnswerRe: Handle Browser close event by pressing [X] Pin
saini arun8-Jun-10 20:20
saini arun8-Jun-10 20:20 
AnswerRe: Handle Browser close event by pressing [X] Pin
Peace ON8-Jun-10 20:29
Peace ON8-Jun-10 20:29 
There is no any permanent connection between your browser
and the server.

So you need to detect browser close event from client side (browser) and
then call server event to execute your code.

You can use master page to avoid writing repeating code on each page.
Find following code for the same.


1. To enable page methods

<asp:scriptmanager id="ScriptManager1" runat="server" enablepagemethods="true" />



2. Detect browser close event.

<body onunload="HandleClose()">



3. Call pagemethods to invoke server side event.

<script language="javascript" type="text/javascript">
  //<![CDATA[
  function HandleClose() 
   {
     alert("Killing the session on the server!!");
      PageMethods.AbandonSession();
   }
   //]]>
</script>



4. Define your page methods at server side and call your code.

C#
[WebMethod]
public static void AbandonSession()
 {
   HttpContext.Current.Session.Abandon();
 }




HTH
Jinal Desai - LIVE
Experience is mother of sage....

GeneralRe: Handle Browser close event by pressing [X] Pin
Herman<T>.Instance9-Jun-10 2:35
Herman<T>.Instance9-Jun-10 2:35 
AnswerRe: Handle Browser close event by pressing [X] Pin
Brij8-Jun-10 20:34
mentorBrij8-Jun-10 20:34 
QuestionModalPopupExtender for node in treeview Pin
yesu prakash8-Jun-10 18:25
yesu prakash8-Jun-10 18:25 
AnswerRe: ModalPopupExtender for node in treeview Pin
Brij8-Jun-10 20:48
mentorBrij8-Jun-10 20:48 
Questiondigital solutions job? What say you Pin
cullyk8-Jun-10 15:13
cullyk8-Jun-10 15:13 
QuestionTextBox.Text after Postback (dynamic textboxes) Pin
AliensXY8-Jun-10 9:40
AliensXY8-Jun-10 9:40 
AnswerRe: TextBox.Text after Postback (dynamic textboxes) Pin
Abhijit Jana8-Jun-10 12:31
professionalAbhijit Jana8-Jun-10 12:31 
GeneralRe: TextBox.Text after Postback (dynamic textboxes) Pin
AliensXY8-Jun-10 13:48
AliensXY8-Jun-10 13:48 
QuestionDataGrid EditTemplate Pin
Paul McGann8-Jun-10 6:48
professionalPaul McGann8-Jun-10 6:48 
AnswerRe: DataGrid EditTemplate Pin
Sandeep Mewara8-Jun-10 6:57
mveSandeep Mewara8-Jun-10 6:57 
Questionimage size in Kb in asp.net c# Pin
trilokharry8-Jun-10 4:46
trilokharry8-Jun-10 4:46 
AnswerRe: image size in Kb in asp.net c# Pin
Sandeep Mewara8-Jun-10 5:04
mveSandeep Mewara8-Jun-10 5:04 
Questioncheckboxes not working Pin
netJP12L8-Jun-10 4:34
netJP12L8-Jun-10 4:34 
AnswerRe: checkboxes not working Pin
Sandeep Mewara8-Jun-10 5:00
mveSandeep Mewara8-Jun-10 5:00 
QuestionRestriction of new password generated using PasswordRecovery control Pin
sahana.C.R8-Jun-10 3:11
sahana.C.R8-Jun-10 3:11 
AnswerRe: Restriction of new password generated using PasswordRecovery control Pin
Peace ON8-Jun-10 4:17
Peace ON8-Jun-10 4:17 
GeneralRe: Restriction of new password generated using PasswordRecovery control Pin
sahana.C.R9-Jun-10 0:00
sahana.C.R9-Jun-10 0:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.