Button clicks everytime I refresh screen???...

T

Trint Smith

What can I do to stop the last button pressed on a page to click when I
refresh the screen?...I created the webproject with visual studio .net
2003 in VB.net.
Thanks,
Trint

..Net programmer
(e-mail address removed)
 
T

Trint Smith

Ok,
For example, I click 'add' to an amount in a textbox...well, if I click
'refresh' in i explorer, it adds again without me clicking add!! Also,
some of my buttons refresh the screen??? What can I do?
Thanks,
Trint

.Net programmer
(e-mail address removed)
 
A

Alessandro Zifiglio

Trint,
The refresh button on IE, is there by design and behaves like that to comply
with the standards set for browser vendors. That is hitting the refresh
button will re-try the previous request you made on the server, in your case
you clicked a button last which will get fired again. The applications you
write should already keep in mind this kind of behavior and try and handle
this yourself gracefully.
1. You can either redirect to a new page --this solves issues when you have
a form that adds data to the database and hitting refresh could add
duplicate data, even though they should not solely depend on this and there
are many other ways to work around this however this does not seem to be
your case.

2. You can track to see if that particular button was already clicked by
setting a flag the first time it were clicked and then do nothing because
now you know its not the button being clicked but a refresh. Use a session
variable to track. Trying to use viewstate to set a flag wont work here
because the postback to the server caused by the refresh button will
postback the same identical data that was posted back last.

In short if someone hit refresh they probably want to refresh the page, that
is resubmit the page and perform the last action they had done, in your case
if they hit refresh after clicking your add button, then they are making
that last request again ;P

Note this is by design and there is not much you can do to prevent this but
your going to have to try and expect this and handle it as gracefully as
possible.

In your case neither 1 or 2 will solve --I'd just let the calculation to add
up anyway. Still I havent been able to reproduce your problem. Your saying
that when the refresh is hit your items are recalculated and a new value is
produced ?
If your making the calculation based on user data that you are collection in
the textbox and then hitting the add button you perform a calculation based
on that . . then the data in the textbox is the same data they had when they
first made the request when clicking the add button so the data produced
after the refresh is the same --how can this be a problem.

It adds the data but the value produced should be the same value anyway so
no problem here. I'm not clear with what you mean by some of your buttons
refresh the screen. I repeat again, so far in your case I dont see how the
refresh button can case your form to give you unexpected behavior.
 
T

Trint Smith

This is an auction site and if they refresh, they bid + $$ again.
Thanks,
Trint

.Net programmer
(e-mail address removed)
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top