ASP.NET Refresh Problem

Discussion in 'ASP .Net' started by wright, Oct 21, 2003.

  1. wright

    wright Guest

    hello, i have a problem in refreshing a page. the problem happens when i
    click a button that does a certain action in a web page, such as inserting a
    record into the database, if now i refresh the page (press f5), the action
    repeats itself and another identical record is inserted too.
    i discovered that the button_click event is called when i refresh the page.
    so the problem is that when i refresh the page, the last action that i have
    done on the page is refired.
    if anybody can tell me how to solve this problem ill be thankfull...
    wright, Oct 21, 2003
    #1
    1. Advertising

  2. You can't exactly solve it. What you can do is to handle it on the server.
    For example, you could set a Session variable when the insert occurs, and
    check it before doing the insert. If the Session variable is there, you know
    the record has been inserted already. Of course, you have to remove the
    Session variable at some point in order to do another insert. But of course,
    there are ways of doing that as well. There are other solutions as well. How
    you handle it is up to you, based upon the functionality of your page, and
    your creativity.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    http://www.takempis.com
    Big Things are made up of
    Lots of Little Things.

    "wright" <> wrote in message
    news:...
    > hello, i have a problem in refreshing a page. the problem happens when i
    > click a button that does a certain action in a web page, such as inserting

    a
    > record into the database, if now i refresh the page (press f5), the action
    > repeats itself and another identical record is inserted too.
    > i discovered that the button_click event is called when i refresh the

    page.
    > so the problem is that when i refresh the page, the last action that i

    have
    > done on the page is refired.
    > if anybody can tell me how to solve this problem ill be thankfull...
    >
    >
    Kevin Spencer, Oct 21, 2003
    #2
    1. Advertising

  3. The problem is that when you press F5 IE sends excatly same info to the
    server.
    And server can not distinguish between first request and second.

    The easiest thing is to redirect to the page (it could be the same page).

    George.

    "wright" <> wrote in message
    news:...
    > hello, i have a problem in refreshing a page. the problem happens when i
    > click a button that does a certain action in a web page, such as inserting

    a
    > record into the database, if now i refresh the page (press f5), the action
    > repeats itself and another identical record is inserted too.
    > i discovered that the button_click event is called when i refresh the

    page.
    > so the problem is that when i refresh the page, the last action that i

    have
    > done on the page is refired.
    > if anybody can tell me how to solve this problem ill be thankfull...
    >
    >
    George Ter-Saakov, Oct 21, 2003
    #3
    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. brian lanning
    Replies:
    0
    Views:
    581
    brian lanning
    Jul 29, 2003
  2. MB
    Replies:
    2
    Views:
    4,118
  3. Per Magnus L?vold
    Replies:
    1
    Views:
    5,094
    John C. Bollinger
    Oct 8, 2004
  4. Pkenty
    Replies:
    0
    Views:
    381
    Pkenty
    May 28, 2004
  5. Jawahar Rajan
    Replies:
    1
    Views:
    279
    Adrienne
    Oct 1, 2003
Loading...

Share This Page