Hi Mark,
After my research, I found that the reason for the intermittent POSTS is
due to a form that gets submitted asynchronously. In other words, closing
IE won't wait for the event to finish Processing.
I found the following workarounds:
1. Submitting the form in a hidden frame
You can have a hidden frame which does the actual submit. The main page can
then ask the frame to post it in its unload handler. If user closes the
browser, then there is no way to do this. You can open a new window, do the
submit and close it.
2. Doing a window.open and submitting the form there.
3. Prolong the onbeforeunload by doing a loop or something similar.
Hope this helps.
Best regards,
Lewis
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| Content-Class: urn:content-classes:message
| From: "Mark Peacock" <mark@fb.com>
| Sender: "Mark Peacock" <mark@fb.com>
| References: <3bda01c37628$3c7202a0$a301280a@phx.gbl>
<8vf#T4ndDHA.1996@cpmsftngxa06.phx.gbl>
<060001c376d7$97774c50$a001280a@phx.gbl>
<ytHprT3dDHA.2080@cpmsftngxa06.phx.gbl>
| Subject: RE: onbeforeunload
| Date: Wed, 10 Sep 2003 12:53:50 -0700
[quoted text clipped - 10 lines]
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.caching:1408
| NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.caching
[quoted text clipped - 252 lines]
| >
| >.
Mark Peacock - 13 Sep 2003 00:02 GMT
Lewis,
I guess the idea of browser application, integrating
client and server processing, is still a stretch; but your
suggestion to prolong onbeforeunload with a loop seems to
do what we need.
Reading a hidden field, updated by code-behind, from
within the loop in onbeforeunload didn't work. Client
script never seemed to refresh the hidden form value to
catch the update. But it did notice an updated cookie
(updated by code-behind) and kick out of the loop to
finish unload.
Relying on cookies isn't perfect, but it's OK on IE-only
intranet.
In case anyone (like me, who is not a client script
expert) can profit by somewhat-tested code, here it is:
<script lang="javascript">
function GetCookie(sName)
{
var aCookie = document.cookie.split("; ");
for (var i=0; i < aCookie.length; i++)
{
var aCrumb = aCookie[i].split("=");
if (sName == aCrumb[0])
return unescape(aCrumb[1]);
}
return null;
}
</script>
<script language="vbscript" id="clientEventHandlersVBS">
<!--
Sub btnShow_onclick
Dim sCookie
sCookie=GetCookieForm1.lstCookies.value)
Form1.txtShow.value = sCookie
End Sub
Sub btnSet_onclick
document.cookie = Form1.lstCookies.value & " = " &
Form1.txtSet.value & "; expires=Fri, 31 Dec 2003 23:59:59
GMT"
End Sub
Sub window_onbeforeunload
Form1.btnSave.click
Do
msgbox(GetCookie("Eval1"))
Loop Until GetCookie("Eval1") = "Done"
End Sub
-->
</script></HEAD>
Code-behind:
Private Sub Page_Load(..
Response.Cookies("Eval1").Value = "Start"
End Sub
Private Sub btnSave_ServerClick(...
' ... delay from server processing
Response.Cookies("Eval1").Value = "Done"
End Sub
Thanks for the help.
MP
>-----Original Message-----
>Hi Mark,
[quoted text clipped - 304 lines]
>
>.