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. how to confirm before accidently closing the page?

how to confirm before accidently closing the page?

Scheduled Pinned Locked Moved ASP.NET
databasesysadminhelptutorialquestion
2 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.
  • S Offline
    S Offline
    steven_wong
    wrote on last edited by
    #1

    Hello everyone: I have a problem that have confused me several days,here is the senario: Some times user may accidently close a page via which some operation may have been submitted to the database,in that case we can use a confirmation msgbox to avoid that. However,if the user really want to close that window ,all the data that have been submit to the database will be no use at all.of course,we can use a sever side code to solve this problem. what i dont know is when the user clicks "yes" (which means he really want to close the page)in the client side ,how can we triggle a server side code to clean all the data that has just been submit to the database?and after that how can we close the page? is there any one who can give me some suggestion? Thank you in advance!

    V 1 Reply Last reply
    0
    • S steven_wong

      Hello everyone: I have a problem that have confused me several days,here is the senario: Some times user may accidently close a page via which some operation may have been submitted to the database,in that case we can use a confirmation msgbox to avoid that. However,if the user really want to close that window ,all the data that have been submit to the database will be no use at all.of course,we can use a sever side code to solve this problem. what i dont know is when the user clicks "yes" (which means he really want to close the page)in the client side ,how can we triggle a server side code to clean all the data that has just been submit to the database?and after that how can we close the page? is there any one who can give me some suggestion? Thank you in advance!

      V Offline
      V Offline
      Vasudevan Deepak Kumar
      wrote on last edited by
      #2

      Hi: It is very easy. Lot of sites do use that. You can check blogs.wwwcoder.com Blog Posting. (1) Within a form or in the essential textboxes/textareas, onKeyUp event, set a JavaScript variable to true (isFormDirty=true). This should have been initialised to false on Window.OnLoad. (2) In onBeforeUnload event handler, you can check (isFormDirty). Like this: onBeforeUnload=return ("Are you sure?"). The browser will append its own messages like 'Are you sure to navigate away from the page etc. Deepak Kumar Vasudevan Personal Web: http://vdeepakkumar.netfirms.com/ I Blog At: http://deepak.blogdrive.com/

      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