473,396 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Back button classic

I have come across a strange behaviour in ASP or rather it could be a
HTML or Browser Issue. The browser here is IE.

The requirement is to re-load the page whenever user click back button
of the browser.

I thought the solution is simple enough: Just set the page to expired,
maintain no cache and Yo! when user clicks back button browser by
default should load fresh copy from server.

But I came across the catch when the page has got a form with method
POST and has an submit button. The catch is that When user hit submit
button on Page1 and then click another button that redirect him to
page2. Now If the Back button is pressed Browser throws the error that
Page can not be displayed.

Can someone please help... what is the cause here & how this can be
rectified?

Here are the sample for your reference:
ASP code for main page 1.asp

<%@ LANGUAGE="VBSCRIPT"%>
<%OPTION EXPLICIT%>
<%
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
Response.Buffer = True
%>
<html>
<head>
<script language=javascript>
function btn2Clicked()
{
document.location="2.asp";
}
function SubmitClicked()
{
//alert("hello");
//document.Form1.submit();
//document.clear;
}
</script>
</head>
<body>
<form action=1.asp method=post ID="Form1" target=_self
onsubmit="SubmitClicked()">
<input type=button name=btn2 onclick=btn2Clicked() value=".."
ID="Button1">
<br>
<input type=text value=<%=now()%ID="Text1" NAME="Text1">
<br>
<%Response.Write(now)%>
<br>
<input type=submit name=btnSubmit value=Submit ID="Submit1">
</form>
</body>
</html>

---------------------------------------
ASP code for Page2 (2.asp)

<%@ LANGUAGE="VBSCRIPT"%>
<%OPTION EXPLICIT%>
<%
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
Response.Buffer = True
Response.Write("<BR>")
Response.Write(now)
Response.Write(" Lets hit back now..")
%>
YOU CAN SIMULATE THE BEHAVIOUR AS STATED BELOW
ON PAGE 1.ASP -CLICK SUBMIT -CLICK BUTTON ".." -CLICK BACK ON
BROWSER

-----------------------
Best Luck
-----------------------

Aug 2 '06 #1
1 2178
HELP PLZ..
ni**********@gmail.com wrote:
I have come across a strange behaviour in ASP or rather it could be a
HTML or Browser Issue. The browser here is IE.

The requirement is to re-load the page whenever user click back button
of the browser.

I thought the solution is simple enough: Just set the page to expired,
maintain no cache and Yo! when user clicks back button browser by
default should load fresh copy from server.

But I came across the catch when the page has got a form with method
POST and has an submit button. The catch is that When user hit submit
button on Page1 and then click another button that redirect him to
page2. Now If the Back button is pressed Browser throws the error that
Page can not be displayed.

Can someone please help... what is the cause here & how this can be
rectified?

Here are the sample for your reference:
ASP code for main page 1.asp

<%@ LANGUAGE="VBSCRIPT"%>
<%OPTION EXPLICIT%>
<%
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
Response.Buffer = True
%>
<html>
<head>
<script language=javascript>
function btn2Clicked()
{
document.location="2.asp";
}
function SubmitClicked()
{
//alert("hello");
//document.Form1.submit();
//document.clear;
}
</script>
</head>
<body>
<form action=1.asp method=post ID="Form1" target=_self
onsubmit="SubmitClicked()">
<input type=button name=btn2 onclick=btn2Clicked() value=".."
ID="Button1">
<br>
<input type=text value=<%=now()%ID="Text1" NAME="Text1">
<br>
<%Response.Write(now)%>
<br>
<input type=submit name=btnSubmit value=Submit ID="Submit1">
</form>
</body>
</html>

---------------------------------------
ASP code for Page2 (2.asp)

<%@ LANGUAGE="VBSCRIPT"%>
<%OPTION EXPLICIT%>
<%
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
Response.Buffer = True
Response.Write("<BR>")
Response.Write(now)
Response.Write(" Lets hit back now..")
%>
YOU CAN SIMULATE THE BEHAVIOUR AS STATED BELOW
ON PAGE 1.ASP -CLICK SUBMIT -CLICK BUTTON ".." -CLICK BACK ON
BROWSER

-----------------------
Best Luck
-----------------------
Aug 3 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Penny | last post by:
Hi all, I've built an online shopping cart using ASP Classic(based on a 'WebThang' tutorial). The shop cart page (with table showing customers selected items and costs) has only 3 buttons/links....
3
by: A.M | last post by:
Hi, When I call FormsAuthentication.SignOut(); the user is not authenticated anymore, but if user clicks on browser's Back button, all previously viewed pages are viewable. How can I prevent...
1
by: Johan Nedin | last post by:
Hello! I am having a problem with the @OutputCache page directive and Web browser Back Buttons. Problem: After setting <%@ OutputCache Location="None" %> on my pages I get the "Warning!...
29
by: Tom wilson | last post by:
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. ...
8
by: Tracey | last post by:
Hi, guys. My application requires functionalities like back and forward navigating button on winforms. And there are many forms linking each other. Each form has a pair of buttons of "Back" and...
182
by: Jim Hubbard | last post by:
http://www.eweek.com/article2/0,1759,1774642,00.asp
9
by: Ant | last post by:
Hi, I'm wondering if anybody can tell me what the Validate document button is used for & how to use it. When I deliberately put some tag in that shouldn't be there, (such as an extra body tag) &...
5
by: Stephanie Le Gall | last post by:
Hello, I have a research form script, a result list script and an item page. Just classic!
1
by: Alkdarf | last post by:
I monitor door cameras with a third party application that gives me multiple video windows for the various video inputs in the card. I want to create an application that will overlay the video...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.