Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Browser's refresh button is reposting data

Posted on 2004-09-13
2
Medium Priority
?
724 Views
Last Modified: 2012-06-22
I have a form on a webpage that a user fills and and then presses the submit button to store the data into a database.  The problem is that if the user presses the Refresh button on thier browser the data is posted a second time.

I have tried adding code that checks to see if the page was submitted already or not, but it is not working.  What am I doing wrong?  I can not redirect them to another page after submitting as this page sets certain panels to visible or not depending on whether or not there submission to the database was sucessful or not.

I set up a global variable called vSubmitted

In the Page_Load section I have the following:
If vSubmitted <> True Then
  vSubmitted = False
End If

Then down in my btnSubmit_Click subroutine I have:
If vSubmitted = False Then
  vSuccess = fnStoreData()
  vSubmitted = True
End If

But, a refresh is still submitting the data again.  Trace shows vSubmitted set to false when the page reloads.

I know that this type of question has been posted before, but I am not getting anywhere with what I have been able to find.

Thanks in advance,
Tom
0
Comment
Question by:TUmphress
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 33

Expert Comment

by:raterus
ID: 12048810
A refresh is always going to repost the data, and it is up to you to figure out if they have already done that or not.  I would say your code to maintain this isn't working properly.  How is your vSubmitted variable persisted?  You can't use viewstate on this one...because you are submitting your old viewstate when you hit refresh, not the new one.
0
 
LVL 18

Accepted Solution

by:
DotNetLover_Baan earned 500 total points
ID: 12048828
Use session to store the flag...
Change btnSubmit_Click subroutine:

If Not Session("vSubmitted") is Nothing Or Session("vSubmitted") = "False" Then
  vSuccess = fnStoreData()
  Session("vSubmitted") = "True"
End If

In Page_Load:

If Not Page.IsPostBack Then
   Session("vSubmitted")="False"
End If
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question