关闭窗口表单,当浏览器或选项卡关闭时,c#,asp.net [英] close window form , when browser or tab is closed , c# , asp.net

查看:78
本文介绍了关闭窗口表单,当浏览器或选项卡关闭时,c#,asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在打开一个窗口的表格和asp.net网页,现在当我关闭浏览器标签或浏览器时,窗口形式仍然存在。

如何在关闭浏览窗口时关闭该窗口表格或tab?

解决方案

混合Windows窗体和ASP.Net是一种不好的做法。它们的工作方式不同,现在有很多方法可以对网页进行编程,使它们的行为几乎完全甚至比Windows窗体(HTML5,jQuery,AJAX,甚至是插件,如JavaFX,Flash和Silverlight)更好。 />




可以使用简单的javascript确认获取确认。它的工作方式类似于是/否消息框:



 <  < span class =code-leadattribute> asp:button     id   =  btnConfirm    runat   =  server    onclientclick   = 返回确认('确认操作? ');    onclick   =  btnConfirm_Click    /  >  





按钮配置abo ve将首先抛出一个确认框,并在c#或VB上捕获你需要提前获得的btnConfirm_Click方法的响应。









您当前的aproach将显示不稳定的行为,例如您所获得的内容,并且将与所有非Windows设备(Apple,Android等)不兼容。 )。


I am opening a window's Form from and asp.net webpage, Now when i close browser tab, or browser, window form remain alive.
How can i close that window form on closing browset or tab ?

解决方案

It is a bad practice to mix Windows Forms and ASP.Net. They don't work alike and nowdays there are ways to program Web Pages to make them behave almost entirely or even better than a Windows Form (HTML5, jQuery, AJAX, or even with plugins sucha as JavaFX, Flash and Silverlight).


A confirmation can be fetched with a simple javascript "confirm". It works like a Yes/No MessageBox:

<asp:button id="btnConfirm" runat="server" onclientclick="return confirm('Confirm action?');" onclick="btnConfirm_Click" />



The button configuration above will first throw a confirm box, and catch the response on c# or VB for the method btnConfirm_Click which you need to have in advance.




Your current aproach will display erratic behavior such as what you're getting, and will be incompatible with all non-Windows devices (Apple, Android, etc.).


这篇关于关闭窗口表单,当浏览器或选项卡关闭时,c#,asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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