在asp.net刷新问题 [英] Problem of Refresh in asp.Net

查看:48
本文介绍了在asp.net刷新问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
在我的应用程序中,gridview中或gridview之外的一个View Linkbutton,单击View linkbutton时,将打开新窗口.问题是何时可以关闭窗口或不关闭窗口.如果我们刷新浏览器,它将打开一个新窗口.如何再次限制打开新窗口.
我正在使用javasciprt,为新窗口编写代码.

Hi guys,
In my Application , One View Linkbutton in gridview or out side the gridview , When clicking on the view linkbutton open the new window popup. The problem is when we can close the window or does not close. If we Refresh the browser, it will open a new window . How to restrict open new window again.
I am using javasciprt ,write code for new window.

推荐答案

如果您通过window.open功能使用javascript打开弹出窗口,则比在弹出窗口中使用无法查看地址栏,菜单等,因此您无法单击刷新按钮,因为它不可见...但是您可以通过按F5键刷新页面,因此请在.aspx页面的脚本标签中写入以下代码块...

//在脚本标签(如
)中编写以下代码块 < script type ="text/javascript">
if you open pop-up window using javascript by window.open funtion than in pop-up window your are not able to view address bar,menu etc so you can not click on refresh button becuase its not visible...but you can refresh page by pressing F5 key so write following block in script tag of .aspx page...

// Write following code of block in script tag like
<script type="text/javascript">
document.attachEvent("onkeydown", my_onkeydown_handler);
window.history.forward(1);
document.attachEvent("onkeydown", my_onkeydown_handler);





function my_onkeydown_handler() {
 switch (event.keyCode) {

      case 116: // 'F5'
          event.returnValue = false;
          event.keyCode = 0;
          window.status = "We have disabled F5";
          window.event.cancelBubble = true;
          break;
      }
  }



</script>

它解决了您的问题....



</script>

its solve your problem....


您是说如果刷新,它会再次显示弹出窗口?我认为这意味着您正在做一些需要回发才能显示窗口的操作?若要停止刷新再次执行回发,请执行Response.Redirect到同一页面,以便浏览器使用GET而不是POST.但是,如果这样做,它将阻止您的代码发出仅在POST上发出的JS,因此也许您只需要修复代码,而不执行回发即可显示弹出窗口.

如果这不是您的意思,则需要对其进行更好的解释.
You''re saying if you do a refresh, it shows the popup again ? I assume this means you''re doing something dodgy that requires a postback to show the window ? To stop a refresh from performing the postback again, do a Response.Redirect back to the same page, so the browser goes a GET instead of a POST. But, if you do that, it will stop your code from emitting the JS that it only emits on a POST, so perhaps you just need to fix your code so it doesn''t do a postback to show a popup.

If that''s not what you mean, you need to explain it better.


这篇关于在asp.net刷新问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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