asp.net页面的后退按钮 [英] Back button of asp.net page

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

问题描述

如何禁用asp.net页面的后退按钮?
我想禁用它,因为它可能不会从浏览器的缓存中显示上一页.但是重新加载上一页并显示它的更新版本...浏览器的按钮仍然处于活动状态,但是我想如果单击后退按钮,则重新加载上一页...

how to disable the back button of an asp.net page?
i want to disable it as in it may not show the previous page from browser''s cache.. but reloads the previous page and show the updated version of it... the browser''s button is still active but i want to reload the previous page if back button is clicked...

推荐答案

如果您要说的是-禁用浏览器的后退按钮",请看一下有关此主题的早些时候在CodeProject上发布的几个问答讨论.

http://www. codeproject.com/search.aspx?q=disable+back+button+%2b+asp.net&usfc=false&doctypeid=4%3b5
If you mean to say - "Disable Browser''s back button", then have a look at several Question-Answer discussions posted on CodeProject earlier on this topic.

http://www.codeproject.com/search.aspx?q=disable+back+button+%2b+asp.net&usfc=false&doctypeid=4%3b5


Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
        Response.AddHeader("pragma", "no-cache");
        Response.AddHeader("Cache-Control", "no-cache");
        Response.CacheControl = "no-cache";
        Response.Expires = -1;
        Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1);
        Response.Cache.SetNoStore();
 
         Page.ClientScript.RegisterStartupScript(this.GetType(), "cle", "windows.history.clear", true);


Or Use Javascript


Or Use Javascript

<script> 
function noBack(){window.history.forward();}
noBack();
window.onload=noBack;
window.onpageshow=function(evt){if(evt.persisted)noBack();}
window.onunload=function(){void(0);}
</script></script>


查看此链接以获取更多信息


^ ]


这篇关于asp.net页面的后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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