Clicking Refresh Button Resubmits Form

Discussion in 'ASP .Net Web Controls' started by Nathan Sokalski, Sep 17, 2005.

  1. I have a form that submits data to a database. If I click the browser's
    refresh button after submitting the form once, the form is submitted a
    second time. How can I avoid this problem? Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/
    Nathan Sokalski, Sep 17, 2005
    #1
    1. Advertising

  2. Nathan,

    You could send the results page a response.redirect or go to a different
    page with a meta refresh. Either way, you need to get the client machine to
    a page that wasn't produced by submitting form data. So the logic would be:

    Client posts form data on submit.

    Server processes data and stores results for future display (if necessary)
    in a session variable or elswhere.

    Server sends client as the result of the form post a redirect or meta
    refresh which sends client to a new page that wasn't produced via posted
    data.

    --
    Sincerely,

    S. Justin Gengo, MCP
    Web Developer / Programmer

    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzsche
    "Nathan Sokalski" <> wrote in message
    news:%...
    >I have a form that submits data to a database. If I click the browser's
    >refresh button after submitting the form once, the form is submitted a
    >second time. How can I avoid this problem? Thanks.
    > --
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/
    >
    S. Justin Gengo, Sep 17, 2005
    #2
    1. Advertising

  3. Nathan Sokalski

    Phil G. Guest

    Would the Page.IsPostback work for you?

    Rgs, Phil

    "Nathan Sokalski" <> wrote in message
    news:%...
    >I have a form that submits data to a database. If I click the browser's
    >refresh button after submitting the form once, the form is submitted a
    >second time. How can I avoid this problem? Thanks.
    > --
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/
    >
    Phil G., Sep 17, 2005
    #3
  4. I tried the Page.IsPostback() and it doesn't help. If I use the condition
    Not Page.IsPostback() then I can't submit at all, and if I use
    Page.IsPostback() it still gives me the resubmitting problem with the
    refresh button.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "Phil G." <> wrote in message
    news:dgi46u$qgr$-infra.bt.com...
    > Would the Page.IsPostback work for you?
    >
    > Rgs, Phil
    >
    > "Nathan Sokalski" <> wrote in message
    > news:%...
    >>I have a form that submits data to a database. If I click the browser's
    >>refresh button after submitting the form once, the form is submitted a
    >>second time. How can I avoid this problem? Thanks.
    >> --
    >> Nathan Sokalski
    >>
    >> http://www.nathansokalski.com/
    >>

    >
    >
    Nathan Sokalski, Sep 18, 2005
    #4
  5. Nathan,

    Any reason why you have the newsgroup AdoNet in this crossposting. In other
    words, with what can we help you that is AdoNet related?

    Cor
    Cor Ligthert [MVP], Sep 18, 2005
    #5
  6. Nathan Sokalski

    Joerg Jooss Guest

    Phil G. wrote:

    > Would the Page.IsPostback work for you?


    This will not work, as refresh resends the last request. A POST thus
    stays a POST...

    Cheers,
    --
    http://www.joergjooss.de
    mailto:
    Joerg Jooss, Sep 18, 2005
    #6
  7. Eliyahu Goldin, Sep 18, 2005
    #7
  8. Go through Teri's article at:-
    http://aspalliance.com/687
    It should help
    Patrick


    "Eliyahu Goldin" <> wrote in message
    news:...
    > Build Your ASP.NET Pages on a Richer Bedrock
    >

    http://msdn.microsoft.com/asp.net/community/authors/dinoesposito/default.asp
    x?pull=/library/en-us/dnvs05/html/bedrockaspnet.asp
    >
    > Eliyahu
    >
    > "Nathan Sokalski" <> wrote in message
    > news:%...
    > > I have a form that submits data to a database. If I click the browser's
    > > refresh button after submitting the form once, the form is submitted a
    > > second time. How can I avoid this problem? Thanks.
    > > --
    > > Nathan Sokalski
    > >
    > > http://www.nathansokalski.com/
    > >
    > >

    >
    >
    Patrick.O.Ige, Sep 19, 2005
    #8
  9. use Redirect to give output that means with redirect the output page
    will be different and now postback will not be there
    Deepak Dhawan, Sep 21, 2005
    #9
    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. lucas
    Replies:
    0
    Views:
    523
    lucas
    Jul 30, 2003
  2. Mike John
    Replies:
    0
    Views:
    320
    Mike John
    Jul 31, 2003
  3. Nathan Sokalski

    Clicking Refresh Button Resubmits Form

    Nathan Sokalski, Sep 17, 2005, in forum: ASP .Net
    Replies:
    8
    Views:
    6,512
    Deepak Dhawan
    Sep 21, 2005
  4. Greg Smith

    weblogic timeout resubmits forms

    Greg Smith, Nov 12, 2004, in forum: Java
    Replies:
    1
    Views:
    1,353
    Greg Smith
    Nov 15, 2004
  5. llbbl
    Replies:
    3
    Views:
    86
    llbbl
    Jun 9, 2006
Loading...

Share This Page