Advertisement
Guest User

Suppress WebBrowser control script error dialogs

a guest
Apr 4th, 2013
1,341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 KB | None | 0 0
  1. private void wbrWebPanel_Navigated( object sender, WebBrowserNavigatedEventArgs e )
  2. {
  3.     SuppressErrorDialogs();
  4. }
  5.  
  6. private void wbrWebPanel_FileDownload( object sender, EventArgs e )
  7. {
  8.     SuppressErrorDialogs();
  9. }
  10.  
  11. /// <summary>
  12. /// Used to suppress error message dialogs from the browser control
  13. /// Not using ScriptErrorsSuppressed as this also suppresses NTLM (and other) dialogs.
  14. /// http://stackoverflow.com/a/7841596/1973027
  15. /// </summary>
  16. private void SuppressErrorDialogs()
  17. {
  18.     if ( wbrWebPanel.Document != null && wbrWebPanel.Document.Window != null )
  19.     {
  20.         this.wbrWebPanel.Document.Window.Error += ( o, args ) => args.Handled = true;
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement