473,836 Members | 1,560 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

When browser is closed i want to call the web method of the webservice .. How can be done.??

Hello,

Can anybody please tell me how to trap the browser close event. when
that is fired I want to call the web method.

Thanks in advance.

Regards,
Gouri.
Jun 27 '08
13 5659
"Munna" <mu******@gmail .comwrote in message
news:27******** *************** ***********@e53 g2000hsa.google groups.com...
when mouse down in browser document traked it down.
Alt-{F4}
Alt F X
Alt-{LEFT} / Alt-{RIGHT}
Ctrl-{F5}

Etc...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #11
On Jun 11, 9:47 pm, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
"Munna" <munna...@gmail .comwrote in message

news:27******** *************** ***********@e53 g2000hsa.google groups.com...
when mouse down in browser document traked it down.

Alt-{F4}
Alt F X
Alt-{LEFT} / Alt-{RIGHT}
Ctrl-{F5}

Etc...

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
Hi

Nice points by Mark...

well here is a simple javascript function that can be used to handle
key events...

this is just an example...

<body onbeforeunload= "doUnload() " onmousedown="so mefunction()">
<form id="form1" runat="server">
</form>
</body>
<script language="javas cript" type="text/javascript">
var isClose = false;

//this code will handle the F5 or Ctrl+F5 key
document.onkeyd own = checkKeycode
function checkKeycode(e) {
var keycode;
if (window.event)
keycode = window.event.ke yCode;
else if (e)
keycode = e.which;

if(keycode == 116)
{
isClose = true;
}
}

function somefunction()
{
isClose = true;
}

function doUnload()
{
if(!isClose)
{
alert('window is closing');
}
}
</script>
Thanks

Munna
Jun 27 '08 #12
Hello Mark Rae [MVP],

yep, my mistake, somehow thought about page close :) not browser

actually, returned to OP quesion there is no 100% way to handle BROWSER closing

what OP could try is to handle top X/Y position and ALT+F4 key

function handleWindowClo se()
{
if((window.even t.clientX<0) || (window.event.c lientY<0))
{
event.returnVal ue = "Closing by X button";
}
}

if (event.altKey== true && event.keyCode== 0 )
{
alert("ALT + F4 ");
}
but thes wont handling closing page from toolbar or killing process from
task manager

---
WBR,
Michael Nemtsev [Microsoft MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
M"Michael Nemtsev [MVP]" <ne*****@msn.co mwrote in message
Mnews:90******* *************** ****@msnews.mic rosoft.com...
M>
>>>No doubt you'll receive other replies suggesting possible solutions
with the unload and/or beforeunload events - none of those works
reliably.. .
Yep, you can use onbeforeunload of the body < body
onbeforeunload ="BrowerClose() ;"and make ajax call to the
web-service
http://www.asp.net/ajax/documentatio...nsumingWebServ
icesWithAJAXTu torial.aspx
MNo you can't. That will fire every time the page closes i.e. moving
Mfrom one page to another, not just when the browser closes...
M>
>it's a common practice for this
MNo it isn't - because it doesn't work...
M>
Jun 27 '08 #13
"Michael Nemtsev [MVP]" <ne*****@msn.co mwrote in message
news:90******** *************** ***@msnews.micr osoft.com...
but thes wont handling closing page from toolbar or killing process from
task manager
Indeed. As has been mentioned, there is no 100% reliable way of doing
this...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
6368
by: James Marshall | last post by:
I'm writing a library where I want to override document.write(), but for all document objects; thus, I want to put it in the prototype. I tried Document.prototype.write= my_doc_write ; but it didn't work. I discovered that this seemed to work: HTMLDocument.prototype.write= my_doc_write ; Why does HTMLDocument work here but not Document? Will this second
2
2266
by: NWx | last post by:
Hi, I have the following question: I have an app that uses user login/logout to identify users When user logon, I register logon time in a session variable When user logoff using the logout link, I also register logoff time and update accordingly the logging history table. However user can simply close the browser without logoff, so his session was closed.
5
9134
by: news.microsoft.com | last post by:
Hi everyone, I need some help (may be in the form of some sample code) for the subject question. I have an ASP.NET/C# application. I need to do quite a few tasks when the session ends. I don't want to depend on the session timeout factor since it may end too soon or it may hang around too long. I can't find any event that fires when the browser closes. The Session_End event handler in the Global.asax does not execute until the...
9
4928
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work fine from a link. The button does bring up the popup window, but when I press the links on the page, it doesn't return or close the window. ****************************************************************************
7
5233
by: Boni | last post by:
Dear all, if I do myform.close() is it disposed or not? is it correct do following? myForm.close() Info=SomeControlOntheForm.text This seems to work. But am not sure that it is waterproof. Thanks, Boni
5
4052
by: Homa | last post by:
Hi all, Can anyone give me some links about how to do an async web service call from aspx and display a temperary page before the web service returns? Thanks, Homa Wong
0
1309
by: Matthew B. Lehrman | last post by:
I've googled all over the place trying to get answer to this question and some things have come close, but nothing quite. Asp.NET 1.1, Visual Studio 2003 I am writing Visual Basic apps. I can create a windows form that can consume and use the webservice. I can also access the webservice through my browser. But when I create an Asp.NET Web Application and try to consume the webservice, I am able to add the web reference, but when I call any...
0
9825
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10553
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10596
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9382
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6980
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5829
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4021
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3116
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.