473,756 Members | 6,106 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 2653
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
20855
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
4605
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
2933
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
18430
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
1332
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
3212
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
2382
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
2456
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
5900
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
9454
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
9271
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,...
0
9868
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...
0
8709
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
7242
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
6533
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
5139
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...
1
3804
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3352
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.