处理后退按钮 [英] Dealing with the Back button

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

问题描述

我不能相信这是不可能的......


我有一个asp.net页面。它通过表单字段接受数据,

包含一个提交按钮。页面加载,你填写一些

的东西。提交按钮将页面发回服务器。

按钮代码检测到输入错误并将页面发送回

用户。这一切都有效。


但是,如果用户此时按下后退按钮,我们返回

并清除所有表格值。我一直在网上

寻找一个解决方案,我所能找到的就是禁用

后退按钮或清除历史记录所以Back won''回去吧。


我也无法得到其中任何一个。我已经尝试将

javascript添加到页面正文顶部:


<%

回复.Buffer = True

Response.ExpiresAbsolute = DateTime.Now.AddDays(-1)

Response.Expires = 0

Response.CacheControl = no-cache

%>


我已经尝试将此添加到Page_Load事件:


Response.Cache.SetCacheability(HttpCacheability.No Cache)


然而我仍然可以使用后退按钮返回空白页面。


这个问题的解决方案是什么?


谢谢!

解决方案

我想尝试一下并不会有什么坏处:


<%@ OutputCache Location =" None" %>


但不保证。


Juan T. Llibre

ASP.NET MVP
http://asp.net.do/foros/

Foros de ASP.NET en Espa?ol

=====================

汤姆威尔逊 <叶******* @ nospam.com>在消息中写道

news:或******************************** @ 4ax.com ...

我不能相信这是不可能的......

我有一个asp.net页面。它通过表单字段接受数据,并包含提交按钮。页面加载,你填写一些
的东西。提交按钮将页面发回服务器。
按钮代码检测到输入错误并将页面发送回
用户。这一切都有效。

但是,如果用户此时按下返回按钮,我们将返回
并清除所有表单值。我一直在网上寻找解决方案,而我所能找到的就是禁用
后退按钮或清除历史记录,以便后面不会回去。

我也不能让其中任何一个工作。我已经尝试将
javascript添加到页面正文的顶部:

<%
Response.Buffer = True
Response.ExpiresAbsolute = DateTime.Now.AddDays(-1)
Response.Expires = 0
Response.CacheControl =" no-cache"
%>

我''尝试将此添加到Page_Load事件:

Response.Cache.SetCacheability(HttpCacheability.No Cache)

然而我仍然可以使用后退按钮返回空白页面。

这个问题的解决方案是什么?

谢谢!



I ''还试过这种方法:


< meta http-equiv =" Expires" CONTENT =" 0>>

< meta http-equiv =" Cache-Control" CONTENT =no-cache>

< meta http-equiv =" Pragma" CONTENT =no-cache>


我可以使用后退按钮返回空白页面。


< blockquote>你是对的!它没有任何区别。 :)


谢谢......


2005年2月16日星期三,11:07:13-10:00,Juan T. Llibre

< no *********** @ nowhere.com>写道:

我想尝试一下并不会有什么坏处:

<%@ OutputCache Location =" None" %>

不保证。

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espa?ol
=====================

汤姆威尔逊 <叶******* @ nospam.com>在消息中写道
新闻:或******************************** @ 4ax.com ..。< blockquote class =post_quotes>我不能相信这是不可能的......

我有一个asp.net页面。它通过表单字段接受数据,并包含提交按钮。页面加载,你填写一些
的东西。提交按钮将页面发回服务器。
按钮代码检测到输入错误并将页面发送回
用户。这一切都有效。

但是,如果用户此时按下返回按钮,我们将返回
并清除所有表单值。我一直在网上寻找解决方案,而我所能找到的就是禁用
后退按钮或清除历史记录,以便后面不会回去。

我也不能让其中任何一个工作。我已经尝试将
javascript添加到页面正文的顶部:

<%
Response.Buffer = True
Response.ExpiresAbsolute = DateTime.Now.AddDays(-1)
Response.Expires = 0
Response.CacheControl =" no-cache"
%>

我''尝试将此添加到Page_Load事件:

Response.Cache.SetCacheability(HttpCacheability.No Cache)

然而我仍然可以使用后退按钮返回空白页面。

这个问题的解决方案是什么?

谢谢!




I can''t believe this is such an impossibility...

I have an asp.net page. It accepts data through on form fields and
includes a submit button. The page loads up and you fill out some
stuff. The submit button posts the page back to the server. The
button code detects an entry error and sends the page back to the
user. This all works.

However, if the user presses the Back button at this point, we go back
and all the form values are cleared. I''ve been all over the web
searching for a solution and all I can find is to either disable the
back button or clear the history so Back won''t go back.

I can''t get either of these to work either. I''ve tried adding the
javascript to the top of the body of the page:

<%
Response.Buffer = True
Response.ExpiresAbsolute = DateTime.Now.AddDays(-1)
Response.Expires = 0
Response.CacheControl = "no-cache"
%>

I''ve tried adding this to the Page_Load event:

Response.Cache.SetCacheability(HttpCacheability.No Cache)

Yet I can still use the back button to go back to a blank page.

What''s the solution to this problem?

Thanks!

解决方案

I suppose it wouldn''t hurt to try :

<%@ OutputCache Location="None" %>

No guarantees, though.

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espa?ol
=====================

"Tom wilson" <ye*******@nospam.com> wrote in message
news:or********************************@4ax.com...

I can''t believe this is such an impossibility...

I have an asp.net page. It accepts data through on form fields and
includes a submit button. The page loads up and you fill out some
stuff. The submit button posts the page back to the server. The
button code detects an entry error and sends the page back to the
user. This all works.

However, if the user presses the Back button at this point, we go back
and all the form values are cleared. I''ve been all over the web
searching for a solution and all I can find is to either disable the
back button or clear the history so Back won''t go back.

I can''t get either of these to work either. I''ve tried adding the
javascript to the top of the body of the page:

<%
Response.Buffer = True
Response.ExpiresAbsolute = DateTime.Now.AddDays(-1)
Response.Expires = 0
Response.CacheControl = "no-cache"
%>

I''ve tried adding this to the Page_Load event:

Response.Cache.SetCacheability(HttpCacheability.No Cache)

Yet I can still use the back button to go back to a blank page.

What''s the solution to this problem?

Thanks!



I''ve also tried this method:

<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">

I can use the back button all I want to return to blank pages.


You were right!!! It made no difference. :)

Thanks tho...

On Wed, 16 Feb 2005 11:07:13 -0400, "Juan T. Llibre"
<no***********@nowhere.com> wrote:

I suppose it wouldn''t hurt to try :

<%@ OutputCache Location="None" %>

No guarantees, though.

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espa?ol
=====================

"Tom wilson" <ye*******@nospam.com> wrote in message
news:or********************************@4ax.com.. .

I can''t believe this is such an impossibility...

I have an asp.net page. It accepts data through on form fields and
includes a submit button. The page loads up and you fill out some
stuff. The submit button posts the page back to the server. The
button code detects an entry error and sends the page back to the
user. This all works.

However, if the user presses the Back button at this point, we go back
and all the form values are cleared. I''ve been all over the web
searching for a solution and all I can find is to either disable the
back button or clear the history so Back won''t go back.

I can''t get either of these to work either. I''ve tried adding the
javascript to the top of the body of the page:

<%
Response.Buffer = True
Response.ExpiresAbsolute = DateTime.Now.AddDays(-1)
Response.Expires = 0
Response.CacheControl = "no-cache"
%>

I''ve tried adding this to the Page_Load event:

Response.Cache.SetCacheability(HttpCacheability.No Cache)

Yet I can still use the back button to go back to a blank page.

What''s the solution to this problem?

Thanks!




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

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