locked
refresh stored data into table RRS feed

  • Question

  • User-2104093092 posted

    hi all,

    i have create a form in asp.net & C# using SQL server..

    after i click save button data will stored in table..

    if i click refresh in browser it save my data again into table..

    what is the problem actually?


    Monday, October 4, 2010 2:02 AM

Answers

  • User-821857111 posted

    If you refresh a page containing a form (which is the case with all ASP.NET Web Forms pages), you submit it back to the server again as a postback. There are a number of ways of Preventing Duplicate Record Insertion On Page Refresh




    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 4, 2010 2:36 AM
  • User-1516073966 posted

    When you refresh the page it will post back again and the button event will be fired. Because browser will reexecute the last action(i.e button click) to prevent this save a value in the session and check the value in the page load event.

    i.e when you are done with saving the data to db set a flag variable in session. in the same button event check if the value is already set or not.


    Or once you are done with the saving just redirect to another page.

    Refer to the post with similar issue:http://forums.asp.net/p/1184197/2140819.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 4, 2010 2:40 AM

All replies

  • User-821857111 posted

    If you refresh a page containing a form (which is the case with all ASP.NET Web Forms pages), you submit it back to the server again as a postback. There are a number of ways of Preventing Duplicate Record Insertion On Page Refresh




    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 4, 2010 2:36 AM
  • User-1516073966 posted

    When you refresh the page it will post back again and the button event will be fired. Because browser will reexecute the last action(i.e button click) to prevent this save a value in the session and check the value in the page load event.

    i.e when you are done with saving the data to db set a flag variable in session. in the same button event check if the value is already set or not.


    Or once you are done with the saving just redirect to another page.

    Refer to the post with similar issue:http://forums.asp.net/p/1184197/2140819.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 4, 2010 2:40 AM