Refresh button

G

Guest

Hi ,
I m new to ASP.NET ...
I have a submit button on my form which adds an user to the DB. I am facing
issue where as after clicking the submit button I refresh the form then
duplicate entries occur in DB i.e the submit button fires again. what would
be the best practice to a avoid this!!!!

Suggestion shall be appreciated,

Cheers,
siaj
 
J

John Timney \(ASP.NET MVP\)

Set a value in viewstate, session object, or the db to indicate that the
page has already been submitted. If its submitted check the value and
reject it if its already been done.

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director
 
T

Tampa.NET Koder

Do not refresh the form. If you need to clear the form, add a html reset
button next to your submit button. Or, in your codebehind, do a
response.redirect() or server.transfer() back to the very same page you are
on after the database insert. Both may work for you.
 
J

Joe Fallon

Dino Esposito wrote an article on how to add an HttpModule to handle this
situation.
Do a Google search for it.
The same problem exists when you refresh a page where you just deleted
something.
The refresh causes something else to be deleted too.
 
G

Guest

The response.redirect() is probably the easiest and quickest method of
getting rid of this problem. Simply redirecting the page to itself will empty
the Request() array and values associated with the submitted form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top