Click here to Skip to main content
15,893,190 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
When My asp.net Application is running on live Server.when Server is responding Slow , User Can click on Save button Multiple time before Successfull Message receive.

If user clicking twice time on button then Two same Record Inserted at one time and then after successful message and all fields blank.How could I resolve this Issue ?
Note in Sqlserver Primary Key ID is Auto Increment Set.
Posted
Updated 24-Jan-14 9:07am
v2

I would disable the submit button after the first click...
 
Share this answer
 
Comments
[no name] 24-Jan-14 9:35am    
how you do it there is so many validation and checks i can not stop and prevent event click after just one click ?
[no name] 24-Jan-14 9:44am    
I've already done this way : Disable button in first on click t then at the end Enabled again also , Still the same issue of Duplicaton.
gettgotcha 24-Jan-14 10:16am    
When are you enabling the button again, after clicking on the button do you navigate to different page something like confirmation page or not?
[no name] 24-Jan-14 10:42am    
no i not navigate the page.
Karthik_Mahalingam 24-Jan-14 21:28pm    
5, Good Idea Ron
you can check whether a record exists or not before inserting it.

you have two options at this point.
1- you may ban an insertion completely if there exists another record having the same fields.
2- you may put a time-limit for it if actually such duplicated data may exist. this option requires additional 'DateTime insertDate' column on your table.

for the first option,
SQL
if not exists select 1 from TableA where ColA=@a and ColB=@b
insert into TableA(ColA, ColB) values(@a,@b)


for the second option
SQL
if not exists select 1 from TableA where ColA=@a and ColB=@b and DATEDIFF(mi,insertDate, GETDATE())<5 
insert into TableA(ColA, ColB, insertDate) values(@a,@b,GETDATE())
 
Share this answer
 
v2
After submitting successfully you can clear all fields & in submit button code you may have used proper validations for blank fields..

Other wise you can use check for duplicate fields in sql query .
 
Share this answer
 
if user click several times then the duplicate data store in the table.to prevent it you can disable the submit button.... or set some logic to stop duplicate insertion.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900