Refresh and Button Click

  • Thread starter Thread starter Fabiano
  • Start date Start date
F

Fabiano

Hi there,

Houston, i have a problem. :O)

I have a page tha contains a datagrid and some textboxes. When the user
clicks the ADD button, i need to insert the textbox data into a table and
then refresh the datagrid data. Ok, but if my user clicks the browser's
refresh button the ASP.NET fires the onClick button again, and again and
again.

I thought i could verify if the data already exists before insert it, but
before this i would like to know if there is anyway i can solve this using
ASP.NET fashion.

Tks in adv.
Fabiano
 
When the user hits the refresh button they are typically prompted by the
browser. The prompt informs them that if they click 'yes' (or is it 'ok'?)
that what the browser will do is execute the last thing the user did to get
the page. If the past thing the user did was click the Add button, then that's
what it will do. Unfortunately this is a user education issue.

There are some things you can do to remove this possibility, such as a Response.Redirect
back into the same page so that it reloads itself from scratch without the
POST sideeffects, but since you're dynamically adding controls in the postback
I think you're going to have a hard time.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
Dino Esposit wrote an article on a "Refresh Trapper" design.
I have used it. It works to disallow these types of things.
Try to google it.
 
Back
Top