none
Can't set a FormClosing event in Visual C# 2012 RRS feed

  • Question

  • I have a form in the body of a .aspx in Visual c# 2012. I want to set a FormClosing event but when I click on the form statement I don't see the Event icon in Properties box.  How can I get the event icon to show up?

    Friday, January 19, 2018 8:29 PM

Answers

  • Nope. The forms in an aspx form do not generate events on the server side. You are mixing them up with the desktop application forms. But the web forms do not operate like that, you will need to rethink the reasons why you wanted such an event. If you want to detect in your server code when the user closes your page in the browser, you are out of luck: the browser does not send anything to the server when it is closed. You can ask in a forum devoted to web applications about some javascript tricks that you can use to send something when the user abandons the page, but none of them is infallible.
    • Marked as answer by D.W.W Saturday, January 20, 2018 10:42 PM
    Saturday, January 20, 2018 9:30 PM
    Moderator

All replies

  • Nope. The forms in an aspx form do not generate events on the server side. You are mixing them up with the desktop application forms. But the web forms do not operate like that, you will need to rethink the reasons why you wanted such an event. If you want to detect in your server code when the user closes your page in the browser, you are out of luck: the browser does not send anything to the server when it is closed. You can ask in a forum devoted to web applications about some javascript tricks that you can use to send something when the user abandons the page, but none of them is infallible.
    • Marked as answer by D.W.W Saturday, January 20, 2018 10:42 PM
    Saturday, January 20, 2018 9:30 PM
    Moderator
  • Thanks Alberto.  Much appreciated.
    Saturday, January 20, 2018 10:43 PM