WebBrowser 2005 : Handling dialog boxes

I am using the 2005 .NET WebBrowser object to automatically navigate through some pages.

Occasionally, the web page navigated to will create a dialog box alerting the user to something that then requires the 'OK' button to be pressed. Of course, this will stop my application from any more automation until the dialog is closed.

I have tried using 'SendKeys.send' for the enter key and spacebar in the 'document_completed' event but that event fires before the message box has focus. Even if it did work, it seems like a hack, since I am just blindly sending this keystroke.

I would prefer to be able to either disable the message box. A 'silent' property (http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/webbrowser/webbrowser.asp) to disable message boxes used to be available but is not in the 2005 version.

OR

I would like to get a handle on this dialog box and control in a more civilized manner that just doing a 'sendkeys'. This would allow me to do 'if...then' on the message contents.

Can anyone please point me in a direction on this?

Thanks,
Richard

[1337 byte] By [RichardBrowne] at [2007-12-16]
# 1
Hi Richard,

If the dialogs that are being displayed are due to scripting errors, you can use the ScriptErrorsSuppressed property to prevent the dialogs from being shown. This is similar to the Silent property of the VB 6 WebBrowser, except the VB 6 version suppressed all dialogs.

Hope this helps,
the V-Bee

shoagMSFT at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2

V-Bee,

Thanks for the note on the scripting messages. I was aware of this property and was hoping to address the other types of message boxes.

Please let me know if you are aware of anything else.

Thanks,
Richard

RichardBrowne at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3

*bump*

Just one more request for help on this before I revamp my methods on this.

Thanks for any help.

Richard

RichardBrowne at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...