开发者

c#.net problem doing Page_unloading

开发者 https://www.devze.com 2023-01-05 20:43 出处:网络
i m using c#.net and in the page_load event i m writing writing..and it should be destroyed when page_unload occurs.but when 开发者_JAVA百科i am doing debugging both page_load and page_unload event tr

i m using c#.net and in the page_load event i m writing writing..and it should be destroyed when page_unload occurs.but when 开发者_JAVA百科i am doing debugging both page_load and page_unload event triggered which was not supposed to be done. like in servlet it runs.

so plz help me i want that doing navigating to other pages i want first when view in browser page_load triggered the navigating to other page_unloading should be happening.


You should look at the ASP.Net page life cycle first. Better read the following link:

http://msdn.microsoft.com/en-us/library/ms178472.aspx


The page lifecycle on the server side does ahere with any client side events. If you want to react on the document load event on client side, you have to write javascript code.

The Page_Unload event is triggered right before the page is sent to the client. If you need an event, which tells you that the document was closed on client side, you will have to use a javascript event.

This should give you an idea of what to do:

<body onunload="__doPostBack('','unloading');" />

If you want to hava a professional implementation hava a look at AjaxControlToolkit. Create a new ScriptControl and use the integrated Callback mechanism.


As standard a web page will not notify the server when a user navigates away from the page. The way it works is when you make a request on the server an object is created for your page. It fires all the events you want such as load. Once it has done everything and sent its content to the client the page object on the server is no longer needed so it is removed and in the process fires its unload event. Once the browser processes the page the unload has already fired and your image path has been destroyed.

What you will want to do is either have an image handler that can deal with whatever image cleanup is needed after the request or a javascript solution as others have indicated to notify the server when the page is unloaded.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号