tags:

views:

182

answers:

3

Why Data manipulation occur when refresh the page in Asp.net

After submit the button to insert data to database table if i press f5 or browser refresh then again dulicate data is inserted why it is maintaining the textbox values and without clicking the submit button it is fired......? provide solution.........

Thanks in Advance..........

+1  A: 

It sounds like you should probably redirect the user after they submit the form. Just a simple Response.Redirect should do it.

Oli
Hi Dear,Thanks For your reply but i am searching for more compactable result because it is time consuming process of 11 seconds.Ones again thanks for your response.....
A: 

In IE when you Press the F5 it tries to do the last executed command. In your case its POST, so the same option happens again. You can handle this in different ways.

  1. Once the Update is done in the data base. Display a Confirmation Message to the User so that s/he will try out the F5
  2. Try to hold a Hidden Field that Maintains the status of the Operation. (First time Hidden field will have a value of New, Once the Insert happens it has the ID of the Inserted Record.)
  3. You can try to handle in the client side to prevent the F5 double post.
Kusek
Hi Dear,Thanks for your response.Please explain the all the methods in details with example is appreciated one....Sory for asking bcoz i am new in asp.net c#Ones again thanks for your response.......
A: 

This doesn't really have anything to do with any particular web technology. When you first display the form, create a hidden field with a random value. Call it something like "transactionID". When the user clicks "Submit", check to see if that random value has already been used. If not, process the form. If so, return "You already submitted this form" or something similar.

Just Some Guy