Refresh and Button Click

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
 
B

Brock Allen

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.
 
J

Joe Fallon

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.
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top