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. Page refresh problem

Page refresh problem

Scheduled Pinned Locked Moved ASP.NET
helpdatabasetutorialquestion
14 Posts 4 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.
  • M Offline
    M Offline
    MihirV
    wrote on last edited by
    #1

    hi all, has anybody idea, how to stop previous request when user refresh the page? More Description... I have 1 Page that have 3 textbox(for entry) and 1 button(Save). on save button click i wrote code to insert data into the database and clear the textbox for new entry and display a message that 'record has been saved'. Now problem is what, when user refresh the page, button click event is re-fired and new record is insered with same previous value. To solve this problem i am checking the same record in database but it is not a good option to solve this problem as per my thinking.. If anybody has solution of this problem, plz help me Thank you(in advance) :(( Mihir..

    E C M G 5 Replies Last reply
    0
    • M MihirV

      hi all, has anybody idea, how to stop previous request when user refresh the page? More Description... I have 1 Page that have 3 textbox(for entry) and 1 button(Save). on save button click i wrote code to insert data into the database and clear the textbox for new entry and display a message that 'record has been saved'. Now problem is what, when user refresh the page, button click event is re-fired and new record is insered with same previous value. To solve this problem i am checking the same record in database but it is not a good option to solve this problem as per my thinking.. If anybody has solution of this problem, plz help me Thank you(in advance) :(( Mihir..

      E Offline
      E Offline
      enjoycrack
      wrote on last edited by
      #2

      hi there, this article might give u a hint for this issue http://www.codeproject.com/aspnet/SyncControl.asp Happy programming << >>

      M 1 Reply Last reply
      0
      • M MihirV

        hi all, has anybody idea, how to stop previous request when user refresh the page? More Description... I have 1 Page that have 3 textbox(for entry) and 1 button(Save). on save button click i wrote code to insert data into the database and clear the textbox for new entry and display a message that 'record has been saved'. Now problem is what, when user refresh the page, button click event is re-fired and new record is insered with same previous value. To solve this problem i am checking the same record in database but it is not a good option to solve this problem as per my thinking.. If anybody has solution of this problem, plz help me Thank you(in advance) :(( Mihir..

        M Offline
        M Offline
        MihirV
        wrote on last edited by
        #3

        Ok i found the solution :) if you people have same query visit http://www.codeproject.com/aspnet/SyncControl.asp#xx764166xx[^] Mihir..

        1 Reply Last reply
        0
        • M MihirV

          hi all, has anybody idea, how to stop previous request when user refresh the page? More Description... I have 1 Page that have 3 textbox(for entry) and 1 button(Save). on save button click i wrote code to insert data into the database and clear the textbox for new entry and display a message that 'record has been saved'. Now problem is what, when user refresh the page, button click event is re-fired and new record is insered with same previous value. To solve this problem i am checking the same record in database but it is not a good option to solve this problem as per my thinking.. If anybody has solution of this problem, plz help me Thank you(in advance) :(( Mihir..

          C Offline
          C Offline
          Chetan Ranpariya
          wrote on last edited by
          #4

          Hi Mihir, Try the following chunk of code. It working finely in my project. Let me know if it works. Response.Cache.SetExpires(DateTime.Now.AddDays(-1)); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetValidUntilExpires(false);

          M 1 Reply Last reply
          0
          • E enjoycrack

            hi there, this article might give u a hint for this issue http://www.codeproject.com/aspnet/SyncControl.asp Happy programming << >>

            M Offline
            M Offline
            MihirV
            wrote on last edited by
            #5

            hi, Thank you very much, i found the same article. Mihir..

            1 Reply Last reply
            0
            • C Chetan Ranpariya

              Hi Mihir, Try the following chunk of code. It working finely in my project. Let me know if it works. Response.Cache.SetExpires(DateTime.Now.AddDays(-1)); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetValidUntilExpires(false);

              M Offline
              M Offline
              MihirV
              wrote on last edited by
              #6

              hi chetan, thanks for your interest.. no, this code only prevent page display from the cache Mihir..

              C 1 Reply Last reply
              0
              • M MihirV

                hi chetan, thanks for your interest.. no, this code only prevent page display from the cache Mihir..

                C Offline
                C Offline
                Chetan Ranpariya
                wrote on last edited by
                #7

                Hi, Thanx for reply. I have one more solution but I will block only "F5" key of ur key board. If u r not displaying the toolbar in ur browser then it will work fine. function checkkey() { if(event.keyCode == 116) { event.keyCode = 0; return false; } }

                E 1 Reply Last reply
                0
                • C Chetan Ranpariya

                  Hi, Thanx for reply. I have one more solution but I will block only "F5" key of ur key board. If u r not displaying the toolbar in ur browser then it will work fine. function checkkey() { if(event.keyCode == 116) { event.keyCode = 0; return false; } }

                  E Offline
                  E Offline
                  enjoycrack
                  wrote on last edited by
                  #8

                  hi there, how about if user want to refresh the web page by right-clicking on the page ? << >>

                  C 1 Reply Last reply
                  0
                  • E enjoycrack

                    hi there, how about if user want to refresh the web page by right-clicking on the page ? << >>

                    C Offline
                    C Offline
                    Chetan Ranpariya
                    wrote on last edited by
                    #9

                    Hi, For that I have solution. try this one.

                    E 1 Reply Last reply
                    0
                    • M MihirV

                      hi all, has anybody idea, how to stop previous request when user refresh the page? More Description... I have 1 Page that have 3 textbox(for entry) and 1 button(Save). on save button click i wrote code to insert data into the database and clear the textbox for new entry and display a message that 'record has been saved'. Now problem is what, when user refresh the page, button click event is re-fired and new record is insered with same previous value. To solve this problem i am checking the same record in database but it is not a good option to solve this problem as per my thinking.. If anybody has solution of this problem, plz help me Thank you(in advance) :(( Mihir..

                      G Offline
                      G Offline
                      Guffa
                      wrote on last edited by
                      #10

                      [Message Deleted]

                      1 Reply Last reply
                      0
                      • M MihirV

                        hi all, has anybody idea, how to stop previous request when user refresh the page? More Description... I have 1 Page that have 3 textbox(for entry) and 1 button(Save). on save button click i wrote code to insert data into the database and clear the textbox for new entry and display a message that 'record has been saved'. Now problem is what, when user refresh the page, button click event is re-fired and new record is insered with same previous value. To solve this problem i am checking the same record in database but it is not a good option to solve this problem as per my thinking.. If anybody has solution of this problem, plz help me Thank you(in advance) :(( Mihir..

                        G Offline
                        G Offline
                        Guffa
                        wrote on last edited by
                        #11

                        One common solution is to do a redirect back to the page. That way the request no longer contains any form data. --- b { font-weight: normal; }

                        C 1 Reply Last reply
                        0
                        • G Guffa

                          One common solution is to do a redirect back to the page. That way the request no longer contains any form data. --- b { font-weight: normal; }

                          C Offline
                          C Offline
                          Chetan Ranpariya
                          wrote on last edited by
                          #12

                          Yes the way u suggested is good. but can we say its a feasible solution?

                          G 1 Reply Last reply
                          0
                          • C Chetan Ranpariya

                            Yes the way u suggested is good. but can we say its a feasible solution?

                            G Offline
                            G Offline
                            Guffa
                            wrote on last edited by
                            #13

                            It works. It's simple. A drawback is that it makes an extra roundtrip to the browser. Also you have to be careful so that you don't lose any querystrings. --- b { font-weight: normal; }

                            1 Reply Last reply
                            0
                            • C Chetan Ranpariya

                              Hi, For that I have solution. try this one.

                              E Offline
                              E Offline
                              enjoycrack
                              wrote on last edited by
                              #14

                              yep I got this. thanx Chetan << >>

                              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