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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Firing a button click event on window close

Firing a button click event on window close

Scheduled Pinned Locked Moved ASP.NET
sysadmin
7 Posts 3 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.
  • R Offline
    R Offline
    Rajiya
    wrote on last edited by
    #1

    Hi, On the close event of the window, I want to call a button click event which is present on the server side. so in the body tag in the onload() i am calling the button click event as follows: function formclose() { var res res = confirm("Do you want to draft this mail, attachments will not be saved.") if(res == false){ window.opener = self; window.close(); } if(res == true) { alert(res); document.getElementById('btnsavclose').click(); } } But only the confirmation meassage is fired and not the button click event. plz suggest me a solution. riz Riz

    I C 2 Replies Last reply
    0
    • R Rajiya

      Hi, On the close event of the window, I want to call a button click event which is present on the server side. so in the body tag in the onload() i am calling the button click event as follows: function formclose() { var res res = confirm("Do you want to draft this mail, attachments will not be saved.") if(res == false){ window.opener = self; window.close(); } if(res == true) { alert(res); document.getElementById('btnsavclose').click(); } } But only the confirmation meassage is fired and not the button click event. plz suggest me a solution. riz Riz

      I Offline
      I Offline
      Imran Khan Pathan
      wrote on last edited by
      #2

      Do u want to call javascript on button click event? If yes , use btn.Attribute.Add in code behind page to call javascript Best regard Pathan

      ---------------------------------------------------

      R 1 Reply Last reply
      0
      • I Imran Khan Pathan

        Do u want to call javascript on button click event? If yes , use btn.Attribute.Add in code behind page to call javascript Best regard Pathan

        ---------------------------------------------------

        R Offline
        R Offline
        Rajiya
        wrote on last edited by
        #3

        No..... I dont want to call a javascript. In my javascript i am calling the button click event in the server code. But the button click event does nt get fired. Plz help me out. Riz

        I 1 Reply Last reply
        0
        • R Rajiya

          No..... I dont want to call a javascript. In my javascript i am calling the button click event in the server code. But the button click event does nt get fired. Plz help me out. Riz

          I Offline
          I Offline
          Imran Khan Pathan
          wrote on last edited by
          #4

          check out ur button object found or not alert(document.getElementById('btnsavclose')); Best Regard pathan

          ---------------------------------------------------

          R 1 Reply Last reply
          0
          • R Rajiya

            Hi, On the close event of the window, I want to call a button click event which is present on the server side. so in the body tag in the onload() i am calling the button click event as follows: function formclose() { var res res = confirm("Do you want to draft this mail, attachments will not be saved.") if(res == false){ window.opener = self; window.close(); } if(res == true) { alert(res); document.getElementById('btnsavclose').click(); } } But only the confirmation meassage is fired and not the button click event. plz suggest me a solution. riz Riz

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            I suspect the form is closing before your method call can do anything. A click involves a postback. A postback involves the page reloading. The page can't close, and reload.

            Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

            1 Reply Last reply
            0
            • I Imran Khan Pathan

              check out ur button object found or not alert(document.getElementById('btnsavclose')); Best Regard pathan

              ---------------------------------------------------

              R Offline
              R Offline
              Rajiya
              wrote on last edited by
              #6

              button object is found. But it does not go to the server side code of the button click. Riz

              I 1 Reply Last reply
              0
              • R Rajiya

                button object is found. But it does not go to the server side code of the button click. Riz

                I Offline
                I Offline
                Imran Khan Pathan
                wrote on last edited by
                #7

                try this if(res == true) { document.getElementById('btnsavclose').click(); return true; } Best regard Pathan

                ---------------------------------------------------

                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