Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have created Employee Registration page with Name, Age, Designation, Id etc. When I have submitting the form record is inserted successfully. Now my issue is when ever refreshing the form again I got the message record is inserted successfully, these process is continue until u close the form or stop refreshing the page. The same records are automatically inserted with previous data. Pls give suggestions how to solve it. Thanks in advanced.
Posted
Comments
Wendelius 21-Aug-15 1:36am    
Please post the relevant code fragments.
Arasappan 21-Aug-15 1:41am    
code behind please.

This happens as on page refresh, it fires the same button click event and thus causing duplicate inserts. There are many ways to do this.
1. Redirect to the same page after insert is done.
C#
Response.Redirect(Request.Url.AbsoluteUri);

2. Put RequiredFieldValidator and clear all the form fields after insert. Also put logic for preventing duplicate data insert in db.
3. [Recommended]
Please follow these links to do it using session & viewstate.
Avoid Duplicate record insert on page refresh using ASP.NET[^]
Avoid inserting twice when user refresh page in ASP.NET[^]

Hope, it helps :)
 
Share this answer
 
It happens due to following reason:

First time you submit the registration and you got the alert message. But after you are refreshing the page again means it is submitting again. Please check your database you will have multiple records.

Please follow below link how to stop refresh page after submitting:
Stop Refresh after Submitting your Request[^]
 
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