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. window closing event

window closing event

Scheduled Pinned Locked Moved ASP.NET
9 Posts 6 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
    Sonia Gupta
    wrote on last edited by
    #1

    have a button in the web page.now on closing the form i am showing the confirm message(are u sure u want to exit). for that i am writing the following code. function abc() { if(confirm('Are u sure u want to exit')==true) { return true; } } but the above code shows me the message box when i click the button.i want the message box to appear when i click the close button. Soniagupta1@yahoo.co.in Yahoo Messenger Id = soniagupta1

    N J P J 4 Replies Last reply
    0
    • S Sonia Gupta

      have a button in the web page.now on closing the form i am showing the confirm message(are u sure u want to exit). for that i am writing the following code. function abc() { if(confirm('Are u sure u want to exit')==true) { return true; } } but the above code shows me the message box when i click the button.i want the message box to appear when i click the close button. Soniagupta1@yahoo.co.in Yahoo Messenger Id = soniagupta1

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      When a button is clicked, obviously this event will fire because you are navigating away from page. To workaround with this issue, make a public variable (JS) and when button is clicked, make this variable value to true. Else it should be false. In your unload function check the status of this variable and show appropriate messages.


      My Website | Ask smart questions

      1 Reply Last reply
      0
      • S Sonia Gupta

        have a button in the web page.now on closing the form i am showing the confirm message(are u sure u want to exit). for that i am writing the following code. function abc() { if(confirm('Are u sure u want to exit')==true) { return true; } } but the above code shows me the message box when i click the button.i want the message box to appear when i click the close button. Soniagupta1@yahoo.co.in Yahoo Messenger Id = soniagupta1

        J Offline
        J Offline
        John ph
        wrote on last edited by
        #3

        check whether you are calling the function on the OnClick event of the button.

        Regards
         - J O N -


        1 Reply Last reply
        0
        • S Sonia Gupta

          have a button in the web page.now on closing the form i am showing the confirm message(are u sure u want to exit). for that i am writing the following code. function abc() { if(confirm('Are u sure u want to exit')==true) { return true; } } but the above code shows me the message box when i click the button.i want the message box to appear when i click the close button. Soniagupta1@yahoo.co.in Yahoo Messenger Id = soniagupta1

          P Offline
          P Offline
          P A N K A J
          wrote on last edited by
          #4

          you can call your javascript methos (that showing confirm message) on "BeforeWindowClose" event of window object in javascript. in this case if a user click on the close button it fires before closing the window.

          Pankaj Gupta (Take it easy)

          S 1 Reply Last reply
          0
          • P P A N K A J

            you can call your javascript methos (that showing confirm message) on "BeforeWindowClose" event of window object in javascript. in this case if a user click on the close button it fires before closing the window.

            Pankaj Gupta (Take it easy)

            S Offline
            S Offline
            Sonia Gupta
            wrote on last edited by
            #5

            Hello Pankaj ... Pankaj how can i write the code it i click yes on the confirm message box.Actually i had to write some code on clicking yes.before the window gets closed. Please help....

            Soniagupta1@yahoo.co.in Yahoo Messenger Id = soniagupta1

            P P 3 Replies Last reply
            0
            • S Sonia Gupta

              have a button in the web page.now on closing the form i am showing the confirm message(are u sure u want to exit). for that i am writing the following code. function abc() { if(confirm('Are u sure u want to exit')==true) { return true; } } but the above code shows me the message box when i click the button.i want the message box to appear when i click the close button. Soniagupta1@yahoo.co.in Yahoo Messenger Id = soniagupta1

              J Offline
              J Offline
              J4amieC
              wrote on last edited by
              #6

              y wld u us txtspk n a cnfm wndw? also y dnt u jst rite ths as:

              function abc()
              {
              return confirm("sme silly txtspk");
              }

              --- How to get answers to your questions[^]

              1 Reply Last reply
              0
              • S Sonia Gupta

                Hello Pankaj ... Pankaj how can i write the code it i click yes on the confirm message box.Actually i had to write some code on clicking yes.before the window gets closed. Please help....

                Soniagupta1@yahoo.co.in Yahoo Messenger Id = soniagupta1

                P Offline
                P Offline
                Piyush Vardhan Singh
                wrote on last edited by
                #7

                u wana close the window when u click the close the button

                Piyush Vardhan Singh

                1 Reply Last reply
                0
                • S Sonia Gupta

                  Hello Pankaj ... Pankaj how can i write the code it i click yes on the confirm message box.Actually i had to write some code on clicking yes.before the window gets closed. Please help....

                  Soniagupta1@yahoo.co.in Yahoo Messenger Id = soniagupta1

                  P Offline
                  P Offline
                  Piyush Vardhan Singh
                  wrote on last edited by
                  #8

                  u use this one page load Button1.Attributes.Add("OnClick", "self.close()")

                  Piyush Vardhan Singh

                  1 Reply Last reply
                  0
                  • S Sonia Gupta

                    Hello Pankaj ... Pankaj how can i write the code it i click yes on the confirm message box.Actually i had to write some code on clicking yes.before the window gets closed. Please help....

                    Soniagupta1@yahoo.co.in Yahoo Messenger Id = soniagupta1

                    P Offline
                    P Offline
                    P A N K A J
                    wrote on last edited by
                    #9

                    window.onbeforeunload = forClose; function forClose() { mess = "You will lose all information provided\nduring navigation of this site"; return mess; } You can use the above code, to confirm while navigating from this page. in the mess variable you can use your message. if you have still any issue mail me. Pankaj Gupta (Take it easy)

                    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