473,383 Members | 1,846 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,383 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 2176
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.