473,597 Members | 2,269 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

smart nav = no unload event

hal
I have an application that includes an activex component
that consumes resources that must be released when the a
page is unloaded.

Toward this end I subscribe to the unload event of the
body of my page in javascript.

However, if I turn on smart navigation, any button that
does a server.transfer fails to fire the javascript unload
event.

I have included two example pages that duplicate the
behavior. To run the example, create two pages called
webform1.aspx and webform2.aspx and copy the html and code
from this message.

Any explanation or work around is greatly appreciated!

Thanks for your time

Hal

*************** *******
Webform1.aspx:
*************** *******
<%@ Page language="c#" Inherits="Syste m.Web.UI.Page"
smartNavigation ="True"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN" >
<HTML>
<HEAD>
<meta name="GENERATOR " Content="Micros oft
Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript"
content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post"
runat="server">
<script language="javas cript">
function __OnLoad()
{
alert("Form1
Load");
}
function __OnUnLoad()
{
alert("Form1
UnLoad");
}
</script>
<script language="C#"
runat="server">
void btnTransferForm 2_Click
(object sender, System.EventArg s e)
{

this.Server.Tra nsfer("Webform2 .aspx");
}
void btnRedirForm2_C lick
(object sender, System.EventArg s e)
{

this.Response.R edirect("Webfor m2.aspx");
}
</script>
<P>Form1.aspx SmartNav=True
</P>
<P><a
href="WebForm2. aspx">Naviagate to
Webform2.aspx</a>&nbsp;this will also fire
the unload event</P>
<P>
<asp:Button
id="btnTransfer Form2" runat="server"
OnClick="btnTra nsferForm2_Clic k" Text="Transfer To
Form2"></asp:Button>&nbs p;click
this button to transfer to
page 2 and see that the unload jscript routine does
not fire</P>
<P>
<asp:Button
id="btnRedirFor m2" runat="server"
OnClick="btnRed irForm2_Click" Text="Redirect To
Form2"></asp:Button>&nbs p;this
will fire the unload event
</P>
<script language="javas cript">
<!--
window.attachEv ent
("onload", __OnLoad);

//document.body.o nload = __OnLoad;
window.attachEv ent
("onunload", __OnUnLoad);

//document.body.o nunload = __OnUnLoad;
-->
</script>
</form>
</body>
</HTML>

*************** ****
Webform2.aspx
*************** ****
<%@ Page language="c#" Inherits="Syste m.Web.UI.Page" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm2 </title>
<meta name="GENERATOR " Content="Micros oft
Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript"
content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post"
runat="server">
<script language="javas cript">
function __OnLoad()
{
alert("Form2
Load");
}
function __OnUnLoad()
{
alert("Form2
UnLoad");
}
</script>
<script language="C#"
runat="server">
void btnTransferForm 1_Click
(object sender, System.EventArg s e)
{

this.Server.Tra nsfer("WebForm1 .aspx");
}

void btnRedirForm1_C lick
(object sender, System.EventArg s e)
{

this.Response.R edirect("Webfor m1.aspx");
}
</script>
<P>Form2.aspx SmartNav=False</P>
<P><a
href="WebForm1. aspx">Naviagate to Webform1.aspx</a></P>
<P>
<asp:Button
id="btnTransfer Form1" runat="server"
OnClick="btnTra nsferForm1_Clic k" Text="Transfer To
Form1"></asp:Button></P>
<P>
<asp:Button
id="btnRedirFor m1" runat="server"
OnClick="btnRed irForm1_Click" Text="Redirect To
Form1"></asp:Button></P>
<script language="javas cript">
<!--
window.attachEv ent
("onload", __OnLoad);

//document.body.o nload = __OnLoad;
window.attachEv ent
("onunload", __OnUnLoad);

//document.body.o nunload = __OnUnLoad;
-->
</script>
</form>
</body>
</HTML>

Nov 18 '05 #1
1 2642
Hi,

You might use RegisterStartup script to render client side script. That
script uses attachEvent to attaché event to event handler
Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2

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

Similar topics

5
20835
by: Harry J. Smith | last post by:
I have written a Visual Basic program that does a long calculation and writes the results to disk as it runs. If I click the Close button the window closes but the program keeps running. How can I get the program to recognize that its window has been closed and quit running? -Harry http://home.netcom.com/~hjsmith
1
4599
by: David A. Beck | last post by:
I have a frameset with an index frame and a main frame. The aspx pages in the main frame are loaded based on the hyperlinks clicked in the index frame. In any aspx page in the main frame I want to save the information in the various controls before the new aspx page is loaded. I thought I could use the Page event Unload, but it does not seem to be triggering when the aspx page is replaced in the frame by another aspx page.
1
2923
by: Hal | last post by:
My most sincere gratitude to anyone who can help me work around this! I have work that needs to be done in javascript on the client whenever a page is unloaded. To this end, I subscribe to the unload event (client side not server side) of the <body> HTML element through javascript.
6
18417
by: Mike | last post by:
I have a web form in my application that will be used for both viewing and updating information. I have a requirement that if any data has been changed on the page and the user attempts to leave the page without saving, the user gets prompted with a message asking if they want to save changes. It seemed logical to put any code to handle this in the page unload event, however the page unload event gets fired every time the page does a post...
1
1327
by: Mike Labosh | last post by:
I have a webform with this event procedure: Private Sub Page_Unload( _ ByVal sender As Object, _ ByVal e As System.EventArgs _ ) Handles MyBase.Unload Logger.Logout(User.Identity.Name) End Sub
3
3206
by: Gauthier Segay | last post by:
Hello, I've an application where all my pages implement a PAGE_CODE string property, this property is stored in HttpContext.Current.Items. In some page, I must persist data in session while the user perform operation on this page (postback navigation based). I also need to clean up the session data when the user leave the page (by a anyway). My question is about the Unload event, is it safe to use the unload
3
2373
by: lesperancer | last post by:
I've got application A, with a hidden form, whose unload event is cancelled unless you use an 'exit' button (so I can do special processing) this works fine when using just application A and it prevents me from 'x'ing out of msaccess.exe now, I open application A from within application B using the code below
11
2432
by: Stevo | last post by:
I've been using the unload event for a long time. I have this code, which I've abstracted and made into a stripped down simple test case below, and it works fine on the major browsers (IE5+, Firefox, Opera). It also works for all Safari versions before 3.1. It's as if they've deliberately made a change to prevent some actions in the unload handler. Has anyone heard of such a restriction? Here's the test case:
5
5892
by: =?Utf-8?B?U3RldmVuIFRhbmc=?= | last post by:
It seems that one page XBAP whose Unloaded event never get called, I need put some clearing stuff (I.G stop dispatcher time) when user close browser, it unload event doesn't work, where shall I put? -- ======================= Steven Tang SYWWUYU)
0
7971
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
7893
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8040
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
8259
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6698
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...
1
5847
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5436
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
3932
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1495
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.