1

I have a WebBrowser control in a WPF application. The browser control is in a grid and when the WebBrowser control renders some webpages, in one of the pages there is popup alert box from the webpage, and when the user taps on the popup the WebBrowser control seems to be closed. I need to capture this close event and take some action.

I already tried subscribing to the unload event but it does not seem to fire. Is there any way to get this event captured?

gram
  • 2,772
  • 20
  • 24
Sanath Shetty
  • 484
  • 1
  • 7
  • 24

1 Answers1

0

There is WindowClosing event on the underlying WebBrowser ActiveX control for that. I haven't tried it myself, but I think it should work.

Here's a full-fledged sample showing how handle the "underlying" WebBrowser events like that. It's for WPF, but it can be easily adapter for WinForms (using WebBrowser.ActiveXInstance).

Community
  • 1
  • 1
noseratio
  • 59,932
  • 34
  • 208
  • 486