472,958 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

Calling a code behind function on onbeforeunload event

I needed to defect when the user is clicking the IE X button ( top
right). so I could execute the cleanup function.

I was able to detect it using onbeforeunload event. Now I need to call
the function in code behind from onbeforeunload event call.

but that is where I have a problem...

please refer my code below

my body tag - <body onbeforeunload = "X_close()">

Javascript - function X_close( ) { if ( window.event.clientX < 0 ||
window.event.clientY < 0) { alert("test") } }

Is there a way I can call Cleanup func from X_close func? or is there
some other way to do this.. Any help appreciated!!!!!!! Thanks!!!

In my post back I have the code below. but this doesn't work.... It
should work I think.

Dim Script As String

Script = "<script language=""javascript"" type=""text/javascript"">"

Script &= "function X_close() { alert(""KKKKK"");}"

Script &= "</script>"

If (Not IsClientScriptBlockRegistered("clientScript")) Then

RegisterClientScriptBlock("clientScript", Script)

End If

Cleanup function ( vb.net)

Private Sub Cleanup(ByVal LineID As Integer)

Dim resourceData As New ResourceMaterial

resourceData.cleanup(LineID)

End Sub

Sep 25 '06 #1
1 9646

le********@hotmail.com wrote:
I needed to defect when the user is clicking the IE X button ( top
right). so I could execute the cleanup function.

I was able to detect it using onbeforeunload event. Now I need to call
the function in code behind from onbeforeunload event call.

but that is where I have a problem...

please refer my code below

my body tag - <body onbeforeunload = "X_close()">

Javascript - function X_close( ) { if ( window.event.clientX < 0 ||
window.event.clientY < 0) { alert("test") } }

Is there a way I can call Cleanup func from X_close func? or is there
some other way to do this.. Any help appreciated!!!!!!! Thanks!!!
[snip]

Yes it's possible. Of course you would also know that vbscript would
only work on IE. But anyways, the following example shows that it
works:

<html>
<head>
<title>example</title>
</head>
<body>
<script type = "text/vbscript">
function vbFunc()
document.write("vbscript")
end function
</script>

<script type = "text/javascript">
function jsFunc()
{
document.write("javascript");
}

vbFunc();
</script>
</body>
</html>

Please make note of the order that they're in. The vbscript must come
first before you are able to call the function. Tested in IE6.

Sep 25 '06 #2

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

Similar topics

6
by: jennyw | last post by:
Hi, I'd like to use onbeforeunload to submit a form before leaving a page. This works in Firefox and IE. Safari, however, blithely ignores this. Does anyone know of a workaround for Safari? Or...
4
by: Zeebra3 | last post by:
Here goes: I have a web form with several asp:dropdownlists, with which, when selection is changed I want to fire an event defined in some clientside js. The content of the clientside code is...
6
by: SP | last post by:
Hi, I want to add wait cursor code whenever page is post back. Page may be post back on my user control's or on change of dropdown or on click of any button on page. so is there any common...
2
by: M B HONG 20 | last post by:
Hi all - I am developing an ASP.NET (C#) application and need some help. I wish to call a server-side function (in the code-behind "file.aspx.cs") upon a user clicking on the "X" to close the...
0
by: teddysnips | last post by:
I have Search form that allows users to retrieve records into a DataGrid. There are two search criteria - a Month and a Year, which are selected from drop-down lists. There is a server-side...
0
by: teddysnips | last post by:
I have Search form that allows users to retrieve records into a DataGrid. There are two search criteria - a Month and a Year, which are selected from drop-down lists. There is a server-side...
8
by: drewmania001 | last post by:
im currently using the following to prompt the user before navigating away from the page // add an unload event window.onbeforeunload = bunload; // function to prompt user function...
1
by: ramgaikwad | last post by:
<script> function checkFormStatus(oForm) { if(isDirty(oForm)) //event.returnValue = "You have entered form Data without submitting this form."; { alert("You have entered form Data without...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.