Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Prevent multple inserts after browser refresh?

Prevent multple inserts after browser refresh?

Scheduled Pinned Locked Moved ASP.NET
questionhelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    FionaDM
    wrote on last edited by
    #1

    Each new record is inserted withn a unique id. The problem is that following insert if the user hits the browser refresh button the same record gets inserted albeit with a new id. How do I stop this happening? Thanks Majella

    P 2 Replies Last reply
    0
    • F FionaDM

      Each new record is inserted withn a unique id. The problem is that following insert if the user hits the browser refresh button the same record gets inserted albeit with a new id. How do I stop this happening? Thanks Majella

      P Offline
      P Offline
      Paddy Boyd
      wrote on last edited by
      #2

      Is your code in page load. Can you put an if not isPostBack around it?

      F 1 Reply Last reply
      0
      • P Paddy Boyd

        Is your code in page load. Can you put an if not isPostBack around it?

        F Offline
        F Offline
        FionaDM
        wrote on last edited by
        #3

        I'm not doing it within page load. I'm doing it with another event handler InsertRecord_Click. I've tried if not IsPostBack within that event i.e. if (!IsPostBack) { SqlDataSource1.Insert(); }; but IsPostBack always comes back false so the record never gets inserted. This strikes me as a common problem which lots of programmers must have encountered - or maybe they haven't noticed! I know that Dino Esposito has set out some advice on how to deal with this problem specifically at http://www.dotmugs.ch/events/event.aspx?eid=17 but I can't get on to it because I don't have a Swiss address. Thanks Majella

        1 Reply Last reply
        0
        • F FionaDM

          Each new record is inserted withn a unique id. The problem is that following insert if the user hits the browser refresh button the same record gets inserted albeit with a new id. How do I stop this happening? Thanks Majella

          P Offline
          P Offline
          Paddy Boyd
          wrote on last edited by
          #4

          You could have a wee look at this: http://www.joel.net/code/refresh_capture.aspx

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups