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

Discussion in 'ASP .Net Web Controls' started by Trint Smith, Feb 23, 2004.

  1. Trint Smith

    Trint Smith Guest

    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


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Trint Smith, Feb 23, 2004
    #1
    1. Advertising

  2. Can you elaborate, I'm not clear with what you want ;P

    "Trint Smith" <> wrote in message
    news:e2hodAl%...
    > 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
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    Alessandro Zifiglio, Feb 23, 2004
    #2
    1. Advertising

  3. Trint Smith

    Trint Smith Guest

    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


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Trint Smith, Feb 24, 2004
    #3
  4. 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.

    "Trint Smith" <> wrote in message
    news:OlPqQ7m%...
    > 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
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    Alessandro Zifiglio, Feb 24, 2004
    #4
  5. Trint Smith

    Trint Smith Guest

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

    .Net programmer


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Trint Smith, Feb 24, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. alanb
    Replies:
    2
    Views:
    514
    alanb
    Apr 23, 2004
  2. Nathan Sokalski

    Code is reexecuted when the user clicks Refresh

    Nathan Sokalski, Jan 19, 2007, in forum: ASP .Net
    Replies:
    5
    Views:
    451
    Spam Catcher
    Jan 20, 2007
  3. PontiMax

    Clicks and double-clicks

    PontiMax, Jul 14, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    176
    Eliyahu Goldin
    Jul 14, 2004
  4. morc
    Replies:
    4
    Views:
    168
    Thomas 'PointedEars' Lahn
    Feb 14, 2006
  5. Badass Scotsman
    Replies:
    1
    Views:
    173
    Randy Webb
    Apr 27, 2006
Loading...

Share This Page