Silverlight 4:OnBeforeUnload
我有一个 silverlight 应用程序,我想捕获浏览器的关闭事件。所以我做了什么,在我的 .aspx 页面中,我有这段代码
function closeIt() {
return "Any string value here forces a dialog box to \n" +
"appear before closing the window.";
}
window.onbeforeunload = closeIt;
,如果触发此功能,将出现一个弹出窗口,您有 2 个按钮“确定”和“取消”。
在 silverlight 或服务器端有没有办法获取用户点击的值?
谢谢
I have a silverlight application and I want to capture the close event of the browser. So what I did, in my .aspx page i have this code
function closeIt() {
return "Any string value here forces a dialog box to \n" +
"appear before closing the window.";
}
window.onbeforeunload = closeIt;
If this functions triggered, a popupwindow will appear, you have 2 buttons OK and CANCEL.
Is there a way in silverlight or in server side to get the value of what the user clicks?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不确定我完全理解你的问题,看起来你正在写 javascript。但你的主题是银光。无论如何......
最简单的方法是在 silverlight 中利用 Html 确认:
或在直接 JavaScript 中:
要将值发送到服务器,您可以将该值存储在隐藏文本字段中并将其发布到服务器。
I am not sure I totally understand your question, it looks like you are writing javascript. But your subject is silverlight. Anyway....
The simplest way is to leverage Html Confirm either in silverlight:
or in straight JavaScript:
To get the value to the server you can store the value in a hidden text field and post it to the server.
为什么不使用 MessageBox ?这是代码示例:
这将为您提供一个弹出窗口,其中包含“确定”和“取消”窗口,并且可以非常简单地确定用户是否单击“确定”或“否”。
Why don't you use MessageBox ? here's code example:
this will get you a popup window with OK and CANCEL window with pretty easy way to determine whether user clicked Ok or no.
答案与我对您之前有关 window.close 的问题的其他答案几乎相同。
当用户选择“取消”时,绝对不会发生任何事情。如果他们选择“确定”,那么您的
Application_Exit
将运行。The answer is pretty much the same as my other answer to your prior question re window.close.
When the user selects Cancel absolutely nothing happens. If they select OK then your
Application_Exit
will run.