473,418 Members | 2,386 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,418 software developers and data experts.

Page Reload After Back Button - Submit Form Twice - Please Help

Hi
Can any one give me some help with this problem please?
Here is the scenario:
A user submits page 1 which is a web form.
After the form has been submitted they are (redirected) onto the next
page, page 2.
The user then clicks back on the browser.
They are now back in page 1
If the user clicks the continue button on page 1 this time the page
just reloads and the user has to click submit again to get to page 2.
In other words after clicking the back button the user has to submit
the form twice. (the first time it does not get submitted the page just

reloads)
Is this a known issue? Can anyone tell me what is causing it and how to

rectify or fix it??
Any help would be greatly appreciated.
Here is the c# code for the page load and also the code for the submit
button:
private void Page_Load(object sender, System.EventArgs e)
{
if(Session["Complete"] == null || Session["Complete"].ToString()
!="complete")
{
Response.Redirect(NormUrl);

}
if(!Page.IsPostBack)
{

bttnContinue.ImageUrl = "Images/Bttn_Continu.gif";
ctrlAddress.PopulateDD();
ctrlAddress.PopulateY();
ctrlAddress.PopulateM();
ctrlAddress.PopulateT();
}
else
{
if(Session["_ViewState"] == null)
{
ctrlAddress.PopulateDD();
ctrlAddress.PopulateY();
ctrlAddress.PopulateM();
ctrlAddress.PopulateT();
}
}
}
private void bttnContinue_Click(object sender,
System.Web.UI.ImageClickEventA*rgs e)
{
string str1Complete = "complete";

ClearErrors();
ctrlAddress.ReadFields();
ctrlAddress.ClearErrors();
bool bOk = ctrlAddress.ValidateFields();
bool bOk1 = ctrlAddress.ValidateAmountYear*s();
if(bOk == true && bOk1 == true)
{
ctrlAddress.CreateSessionVaria*bles();
Session["1Complete"] = str1Complete;
Response.Redirect("2.aspx");
}
if(bOk == true && bOk1 == false)
{
ctrlAddressDetails.CreateSessi*onVariables();
Session["1Complete"] = str1Complete;
Response.Redirect("1a.aspx");
}
else
divOrderError.InnerHtml = "Blah.";
divOrderError2.InnerHtml = "blah.";
return;

Nov 17 '05 #1
2 3826
Frawls wrote:
Hi
Can any one give me some help with this problem please?
Here is the scenario:
A user submits page 1 which is a web form.
After the form has been submitted they are (redirected) onto the next
page, page 2.
The user then clicks back on the browser.
They are now back in page 1
If the user clicks the continue button on page 1 this time the page
just reloads and the user has to click submit again to get to page 2.
What is the "continue" button?
In other words after clicking the back button the user has to submit
the form twice. (the first time it does not get submitted the page
just

reloads)
Is this a known issue? Can anyone tell me what is causing it and how
to

rectify or fix it??


I'm not sure I understand your problem, but to me it seems as though
you've just discovered redirect-after-post. What happens is that in the
browser history, only the final request/response of a redirect chain is
saved.
In your case, it looks like this:
POST /p1.aspx --> 302 Found Location: /p2.aspx
GET /p2.aspx --> 200 OK

The browser only saves the last GET in its history. Thus, the POST is
never resubmitted by the browser when pressing refresh or back, which
is the reason why this pattern is actually quite useful ;-)

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 17 '05 #2
Frawls wrote:
Hi
Can any one give me some help with this problem please?
Here is the scenario:
A user submits page 1 which is a web form.
After the form has been submitted they are (redirected) onto the next
page, page 2.
The user then clicks back on the browser.
They are now back in page 1
If the user clicks the continue button on page 1 this time the page
just reloads and the user has to click submit again to get to page 2.
What is the "continue" button?
In other words after clicking the back button the user has to submit
the form twice. (the first time it does not get submitted the page
just

reloads)
Is this a known issue? Can anyone tell me what is causing it and how
to

rectify or fix it??


I'm not sure I understand your problem, but to me it seems as though
you've just discovered redirect-after-post. What happens is that in the
browser history, only the final request/response of a redirect chain is
saved.
In your case, it looks like this:
POST /p1.aspx --> 302 Found Location: /p2.aspx
GET /p2.aspx --> 200 OK

The browser only saves the last GET in its history. Thus, the POST is
never resubmitted by the browser when pressing refresh or back, which
is the reason why this pattern is actually quite useful ;-)

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 17 '05 #3

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

Similar topics

9
by: | last post by:
When I complete a <FORM METHOD=POST> and I press <INPUT TYPE=SUBMIT> a new page was arrive. Then, if I press browser back button it says that: "page has expired". Why??? Can I fix it or it is...
4
by: fig000 | last post by:
Hi, I'm relatively new to Javascript so please bear with me on what might sound like silly questions. This is what I want to do: I'm working in classic asp (I have to for this project). I...
6
by: iwearwatches | last post by:
Group, What a root canal. Here is what I have: I have a page that has several layers that I will either show/hide based on a graphic/tab that the user clicks. (works perfectly)
1
by: Frawls | last post by:
Hi Can any one give me some help with this problem please? Here is the scenario: A user submits page 1 which is a web form. After the form has been submitted they are (redirected) onto...
8
by: Galina | last post by:
Hello I have 6 dependent list boxes on my ASP page:  Faculty;  Lecturer;  Course;  Course occurrence;  Group;  Week commencing date. When faculty is selected, lists of lecturers and...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
9
by: Chris | last post by:
I pop up a Modal form on a web page that allows the user to update the selections of a dropdownlist via adding a new item to the db (Sql Server).The only thing is this list is on the page beneath...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
7
by: Schmidty | last post by:
Okay...I have another 'newbie' question; I have a function that loads a page and the action is $_SERVER; In the form that is in a function(method?) within a class a variable is passed back to...
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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.