Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
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
 
Old August 23rd, 2004, 08:39 PM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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. :)

 
Old August 23rd, 2004, 09:08 PM
Authorized User
 
Join Date: Aug 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 !
 
Old August 23rd, 2004, 10:57 PM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks desmond047. I am looking for other senarios as well. (i.e) what happens of your Primary key is identity column.

 
Old August 24th, 2004, 01:30 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

. 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...
 
Old August 24th, 2004, 11:01 PM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Santhi. Guys Any More Suggestions? I am still looking fer the Best Practise.
 
Old August 29th, 2004, 08:20 PM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Guys, Anymore better suggestions?

 
Old August 30th, 2004, 09:12 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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
 
Old September 1st, 2004, 10:12 AM
Authorized User
 
Join Date: Jul 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Prevent IE alert message ? Master123 Pro Java 2 September 1st, 2007 10:29 AM
How to submit the different data on single submit pushpa Classic ASP Databases 1 January 24th, 2007 07:10 PM
"Prevent User " javauniverse Pro VB Databases 3 January 9th, 2004 05:07 PM
How to prevent submit back bveerendrakumar Classic ASP Basics 3 November 11th, 2003 01:21 AM
How can we submit a form without a submit butto phpsharma BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 4 October 20th, 2003 08:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.