473,675 Members | 4,740 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Not allowing user to resubmit the same page again.

5 New Member
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 1342
prabunewindia
199 New Member
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 Recognized Expert Contributor
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".Yo u 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 Recognized Expert Moderator Expert
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 Recognized Expert Moderator Expert
Oh I forgot to mention that if you use that JavaScript suggestion you will have to set the button's UseSubmitBehavi our to be false.

:)

-Frinny
Jun 19 '07 #5

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

Similar topics

5
1740
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 user the ability to modify entries. By either clicking on a link or a button on each row, I want the user to be sent to another page to edit that entry. What is the best way to track which entry the user is wanting to edit? Thanks for...
3
1578
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 particular site that they would like to edit. The second would allow the user to select which admin screen they would like to edit. The second dropdown needs to be populated based on the selection in the first one. I want to encapsulate these...
1
1279
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 controls to the same array - so page_load runs, then the control's event handler, but I can't handle the events of the new controls, because I didn't load them during page_load - simplest solution seems to be to store the lot in session memory and...
7
2914
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 database into classes, which are used throughout the application. I have made class collections which, upon reading from the DB, create an instance of the class and store the DB values in there temporarily. My problem is that if user1 looks at...
6
3737
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 user get used to click "enter" key to submit a form. How can I use "enter" key to submit/postback in ASP.NET. Thank, Guoqi Zheng
0
1321
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 forecasting information. To make the spreadsheet easy to use, all cells are Protected except the cells where the user will enter information. However, since the information is presented in hierarchical layers, I need to do grouping/outlining of the...
3
1778
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 and ran into a strange problem. After roughly 3 minutes of processing, the application reprompted the user for their user name and password (NT authentication). At this point, the ASP.NET page re-fired the last event that it was processing.
0
802
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 this at a higher level (httpmodule or httphandler ?) and let them know that a job is running. Scenario: A user has made a few requests in the app and on their next request for a page, the app checks to see if the job is running, and if so,...
9
3185
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 load with different data (locations, departments, etc.).
0
8512
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8440
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8860
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8667
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6274
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4259
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2115
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.