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. stop data saved twice when page is refreshed

stop data saved twice when page is refreshed

Scheduled Pinned Locked Moved ASP.NET
question
4 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.
  • N Offline
    N Offline
    nitin_ion
    wrote on last edited by
    #1

    How can i stop data saved twice when page is refreshed

    D N H 3 Replies Last reply
    0
    • N nitin_ion

      How can i stop data saved twice when page is refreshed

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      Might help[^].

      1 Reply Last reply
      0
      • N nitin_ion

        How can i stop data saved twice when page is refreshed

        N Offline
        N Offline
        nitin_vatsus
        wrote on last edited by
        #3

        1. Redirect your page on new location when data is successfully saved when user refresh the page it found new page refreshed which is not contains any sort of data saving code. 2. Clear all the state of controls after data saving and write state check condition before data save but I think first approach is better approach if you found any difficulty then I will send you sample code but remember if user go back to page and repeat same activity then you have to give dynamic image by that you always check random image code before saving same as in yahoo, google.

        1 Reply Last reply
        0
        • N nitin_ion

          How can i stop data saved twice when page is refreshed

          H Offline
          H Offline
          harish mehra
          wrote on last edited by
          #4

          you just paste it below your class declaration private bool _refreshState; private bool _isRefresh; public bool IsRefresh { get { return _isRefresh; } } protected override void LoadViewState(object savedState) { object[] allStates = (object[])savedState; base.LoadViewState(allStates[0]); _refreshState = (bool)allStates[1]; _isRefresh = _refreshState == (bool)Session["__ISREFRESH"]; } protected override object SaveViewState() { Session["__ISREFRESH"] = _refreshState; object[] allStates = new object[2]; allStates[0] = base.SaveViewState(); allStates[1] = !_refreshState; return allStates; } and in button click if (!IsRefresh) { //write your code here.. }

          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