N
nileshsoni21
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
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