Warning when closing the browser

Answered
0
0

I implemented a function in the FormClosing event and it works great, but if I close the browser (or the Tab), obviously, this event is not called. I know there is a way to send a message before closing and a long time ago in Asp.net I had inserted it, but with Wisej I don’t know how to do it. Can anyone help me?

  • Luca (ITG)
    You can also handle the Application.ApplicationExit event or the Page or Form Dispose event. They will fire when the session is disposed, at session timeout * 2. See SessionManagement in our docs.
  • You must to post comments
Best Answer
0
0

The solution is simple, you just need to know it, I’ll publish it so that someone can use it as a simple and effective answer.

In the Main Method, or wherever it is useful, just write:

Application.EnableUnloadConfirmation = true;

That’s all folks.

Greetings

  • You must to post comments
0
0

It’s not an event, it’s  a property. Set it to true and the browser will show its standard alert. If you to run javascript code on the unload or beforeunload event you can simply add javascript to your default.html page. Search for unload or beforeunload.

  • You must to post comments
0
0
Hi Francesco,
I would also like to point out the following:

The unload event in all browsers is the same for navigating or closing. All you can do is enable the browser’s alert and cancel closing the tab or navigating away.

It is not possible to process a server request when closing the tab or navigating away or closing the browser.
Best,
Alaa

//

  • Francesco Leo
    You’re right, but I don’t know how to enable the warning.
  • You must to post comments
0
0

Hi Francesco,

You can use the Application.BrowserTabDeactivated event for now, it might cause a few issues if your users are constantly switching between tabs.

This could be an enhancement for a future release, I’ll log it and update you ASAP!

EDIT: I would like to point out that we do have an event Application.EnableUnloadConfirmation that you can use!

Best,
Alaa

  • Francesco Leo
    Ok, but can you help me understand where to intercept and handle the .onbeforeunload event in Wisej? I can’t understand it. Thanks for your help.
  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.