页面关闭时需要从代码隐藏中引发事件 [英] Need to raise event from codebehind when Page is closed

查看:53
本文介绍了页面关闭时需要从代码隐藏中引发事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi


我在页面加载时将值赋给静态字段,可以在页面的各种操作中使用。但最后当页面被关闭时,我必须将null值分配给相同的静态字段。



当页面关闭时,任何人都可以帮助引发事件,以便为静态字段分配空值。或者任何其他方式来做到这一点?感谢你的帮助.....





谢谢

Hi
I am assigning the value to a static field at page load, which can be used in various operation of the page. But finally when page is being closed, I have to assign null value to the same static field.

Can anybody help to raise an event when the page is being closed so that to assign null value to static field. Or any alternate way to do this? Appreciate your help.....


Thanks

推荐答案

没有办法做到这一点。您可以在页面关闭时向页面添加AJAX调用,但您无法确定它是否会被调用,使其接近无用。我假设您知道浏览器关闭时没有页面生命周期,因此根本没有服务器端代码运行。



您的设计听起来有点奇怪,我建议你更好的地方存储东西就是会话,所以只有当前用户可以看到它并且关闭浏览器时没关系
There is no way to do this. You can add an AJAX call to your page when the page is closed, but you can''t be certain it will be called, making it close to useless. I assume you know there''s no page lifecycle when the browser is closed, and so no server side code runs at all.

your design sounds a bit odd, I''d suggest your better place to store things is the session, so only the current user can see it and it doesn''t matter when they close the browser


这篇关于页面关闭时需要从代码隐藏中引发事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆