Refresh and Button Click

Discussion in 'ASP .Net' started by Fabiano, May 30, 2005.

  1. Fabiano

    Fabiano Guest

    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

    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, May 30, 2005
    1. Advertisements

  2. Fabiano

    Brock Allen Guest

    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.
    Brock Allen, May 30, 2005
    1. Advertisements

  3. Fabiano

    Joe Fallon Guest

    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.
    Joe Fallon, May 31, 2005
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.