473,396 Members | 1,713 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.

Not allowing user to resubmit the same page again.

I have a problem. I have developed a page which inserts data into database and redirects me to some other page. but when user click the back button from top its takes him to the last page and all the details are resubmitted if user pressess submit button.

does any body have idea how to stop user from re-submitting the last page or expire the last page so that details is inserted only once.
Jun 19 '07 #1
4 1333
prabunewindia
199 100+
hi friend,
did u try with ViewState property?
initially it is set to true. you can make it as false. so the data will be erased when it redirected to other page
try and reply(i am not having exp in it. theory i know)
prabu

I have a problem. I have developed a page which inserts data into database and redirects me to some other page. but when user click the back button from top its takes him to the last page and all the details are resubmitted if user pressess submit button.

does any body have idea how to stop user from re-submitting the last page or expire the last page so that details is inserted only once.
Jun 19 '07 #2
dip_developer
648 Expert 512MB
I have a problem. I have developed a page which inserts data into database and redirects me to some other page. but when user click the back button from top its takes him to the last page and all the details are resubmitted if user pressess submit button.

does any body have idea how to stop user from re-submitting the last page or expire the last page so that details is inserted only once.
There are many ways to do that...

1.You can check in the Page_Load event for PostBack. If the page is Posted back then Disable the SUBMIT button(you must have one).

Expand|Select|Wrap|Line Numbers
  1.  If Not Page.IsPostBack Then 
  2. btnSubmit.Enable=True
  3. else
  4. btnSubmit.Enable=False
  5. End If
  6.  
2.You can also change the text of SUBMIT button to "UPDATE".You can run a UPDATE query if button text is "UPDATE".

Expand|Select|Wrap|Line Numbers
  1.  If Not Page.IsPostBack Then 
  2. btnSubmit.Text="SUBMIT"
  3. else
  4. btnSubmit.Enable="UPDATE"
  5. End If
  6.  
3.Finally you can always check for a duplicate entry by Unique Primary Key (or by some sql) in your table.
Jun 19 '07 #3
Frinavale
9,735 Expert Mod 8TB
Hi there!
Dip_developer suggestions are great and could solve the problem for you but please remember that when the user hits the back button a Cached version of your web page is displayed. This means that the user will have to submit the forum and you'll have to do some checking to see if they have already submitted that data.

I recommend using JavaScript to disable the button upon submitting the page.
All you have to do is:
Expand|Select|Wrap|Line Numbers
  1. BTN_Button.Attributes.Add("onclick", "javascript:" + BTN_Button.ClientID + ".disabled=true;"
Now when the user clicks the button the page is submitted to the server and the button is disabled. If you need to redisplay the page with errors the JavaScript will also be reset so the button will become usable at that time. Otherwise, if the user clicks the back button the Chached web page displayed will have the button disabled.

Please remember that there are ways around JavaScript scripts, so always do server side checks to properly secure your program.

:)

Cheers!

-Frinny
Jun 19 '07 #4
Frinavale
9,735 Expert Mod 8TB
Oh I forgot to mention that if you use that JavaScript suggestion you will have to set the button's UseSubmitBehaviour to be false.

:)

-Frinny
Jun 19 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Mark Feller | last post by:
I want to provide users a page where they can browse entries in a database 10 at a time, for example. I am doing this as a table, where each row is a database entry. I want to be able to give the...
3
by: Damon | last post by:
I am working on a site in which I would like to have two dropdowns that will allow a user to navigate through the administrative pages of the site. The first would allow the user to choose the...
1
by: Nick Stansbury | last post by:
Hi, Is there any way to cause a page to completely resubmit itself from the server side? I have an array of user controls that, in the event handler of the user control itself, add new user...
7
by: jsale | last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app i have made is running on IIS v6 and consists of a number of pages that allow the user to read information from the...
6
by: guoqi zheng | last post by:
In a regular html form, when user press "enter" key, the form will be submitted. However, in ASP.NET web form, a form will only be submitted (post back) when a special button is clicked. Many...
0
by: Joe Schmoe | last post by:
I am working on an ASP.NET application that generates an Excel 2003 spreadsheet on demand for the user, containing much sales information, and then editable cells for the salerep user to enter...
3
by: Funky | last post by:
Hi, I have developed an ASP.NET application which has been running in production for around 3 months without any major glitches. Recently, a user was attempting to upload a rather large CSV file...
0
by: ack95 | last post by:
Not sure how to go about this? If we have a sql agent job running, we would like to keep a user from hitting the database via our web app while this 1-2 minute job runs. Ideally we could catch...
9
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will...
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: 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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.