到Response.End后,关闭窗口 [英] closing a window after Response.End

查看:1057
本文介绍了到Response.End后,关闭窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如。我有一个的ListView 这是在编辑模式下的一种形式。结果
有事让ListView控件使用表不再可用。结果
我只是希望能够当用户点击保存,关闭窗口。

e.g. I have a form with a ListView that is in edit mode.
Something happens so that the table the Listview is using is no longer available.
I just want to be able to close the window if the user hits 'save'.

在Page_Load中,我检查表可用,如果没有,我称之为的RegisterClientScriptBlock(类型,名称,window.close()的)。然而,处理仍然存在,并成为L istView1_ItemUpdating事件

In Page_Load, I check if the table is available, if not, I call RegisterClientScriptBlock(type,name,"window.close()"). However, processing still occurs, and it goes to ListView1_ItemUpdating event.

的Page_Load ,如果表不存在,我可以打电话到Response.End停止处理,但是,仍然窗口熬夜因为脚本从不注册。

In Page_Load, if the table doesn't exist, I can call Response.End to stop processing, however, the window still stays up since the script never registered.

任何方式停止处理并关闭窗口,而不必把一个自定义的 IsTableValid()在我所有的方法检查?

Any way to stop processing and close the window without having to put a custom IsTableValid() check in all of my methods?

推荐答案

一个解决方案,kludgey,但可以在其他地方使用的:

one solution, kludgey, but can be used elsewhere:

的Response.Redirect(close.html)

其中, close.html 只是有

  <script>
  window.close();
  </script>

这篇关于到Response.End后,关闭窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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