 |
| General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category.
** PLEASE BE SPECIFIC WITH YOUR QUESTION **
When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

August 23rd, 2004, 08:39 PM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Prevent Submit Twice
Hi All,
In a senario where I have a web form which capture a product details, I want to prevent the data to be inserted twice to the database, either by pressingthe submit button more than once or click on the refesh button after saving the data. What are the best practices. Your suggestions are highly appreciated. :)
|
|

August 23rd, 2004, 09:08 PM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
1st of all your primary key of the data is unique and u can use it to do comparison whether the data has been inserted into the db. it is not possible to click the submit button twice in a webform. it will only submit once per click, and refresh will not affect too.
~ Human Knowledge Belongs to the World !
|
|

August 23rd, 2004, 10:57 PM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks desmond047. I am looking for other senarios as well. (i.e) what happens of your Primary key is identity column.
|
|

August 24th, 2004, 01:30 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
. After you submit the data to insert ,disable the submit button..
. When you refresh the page,check for the mandatory fields you have inserted in the database whether it exists or not.
This way u can prevent data to be inserted twice...
|
|

August 24th, 2004, 11:01 PM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks Santhi. Guys Any More Suggestions? I am still looking fer the Best Practise.
|
|

August 29th, 2004, 08:20 PM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Guys, Anymore better suggestions?
|
|

August 30th, 2004, 09:12 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
if we had any other suggestions we would give them to you- however, there are not better suggestions. There are only "hacks" to prevent double submit, there is no built in way.
Hal Levy
Web Developer, PDI Inc.
NOT a Wiley/Wrox Employee
|
|

September 1st, 2004, 10:12 AM
|
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
According to me the best way to handle your situaltion is to check for the duplicate data before you save.
Use customvalidator in your web form and in the validate event check in the database whether the particular field data in a row being added is not duplicated by calling stored procedure. You can take the next action based on the results returned.
|
|
 |