Refreshing the browser after an insert creates an additional record

A

Adam Sandler

Hello,

This problem came up during testing. There's a button on the page and
when a user selects the button, a row is added to the database.

If the user refreshes the browser (View | Refresh or F5) then a
duplicate of the previously inserted record is added to the database.

Calling dispose on the table adapter inside the event handler for the
button click doesn't help.

Suggestions are greatly appreciated.

Thanks!
 
B

Brock Allen

Suggestions are greatly appreciated.

Did the browser prompt you with a dialog after you hit refresh? The dialog
says something like "I'm going to do the POST again -- you sure that's what
you wanted?"

It's a user education issue. Educate the users the meaning of the dialog.
If that's insurmountable, after the update do a Response.Redirect(Request.Path)
to bring them into the page as if it were for the first time. That way if
they hit refresh it'll just be a GET again.
 
B

bruce barker \(sqlwork.com\)

you will have the same issue with the back button. its better practice to
code your site to support reposting of the same data. site that display
messages like "don't hit send again or you''l be charged twice" are just
bush league.

-- bruce (sqlwork.com)
 
A

Adam Sandler

Thanks for the reply... I have some inline comments to your response
below...
bruce barker (sqlwork.com) wrote:
you will have the same issue with the back button. its better practice to
code your site to support reposting of the same data.

I'm new to ASP; I though when I called DataBind it did that... could
you extrapolate what you mean by "its better practice to code your site
to support reposting of the same data."
site that display
messages like "don't hit send again or you''l be charged twice" are just
bush league.

I wholeheartedly agree... and it never ceases to amaze me with what
users can find -- no matter how comprehensive I believe a given test
case to be.
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top