Turn your Mobile Apps into m-commerce apps – Learn More!

You're Browsing As A Guest! Register Now...
Become a VB.NET Expert!

Join 416,729 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 2,946 people online right now.Registration is fast and FREE... Join Now!



Page 1 of 1
  • You cannot start a new topic
  • Reply Reply

How to Suppress a Web-Dialog Want to suppress a Web-Dialog while loading a web-page Rate Topic: -----

#1 kasbaba  Icon User is offline

  • D.I.C Head
  • PipPip

Reputation: 23
  • View blog
  • Posts: 132
  • Joined: 03-November 08


Dream Kudos: 0

Share |

How to Suppress a Web-Dialog

Posted 04 November 2008 - 11:10 AM

Hi,

This is my first post, and I will take every caution to follow the Forum rules.

Problem Statement : I have a form with a Web browser control. I am trying to load a web-page and search for some user information once the page is loaded. The problem however is that this particular web-page has a web-dialog box, which shows up when the website is loaded for the first time.

I can't seem to find any method to suppress it.

I have tried the Web browser's setting named ScriptErrorSuppressed, and even tried Sendkeys however nothing seems to work.

The code so far is as follows :

WebBrowser.Navigate("http://xxx.net/getuserinfo/id?XXXX")


Please help...

Thanks

kasbaba
Was This Post Helpful? 0
  • +
  • -


#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • Icon

Reputation: 1401
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07


Dream Kudos: 12950

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

Re: How to Suppress a Web-Dialog

Posted 04 November 2008 - 11:48 AM

This is a known issue with the WebBrowser control in VB.NET. One thing you can do is to attach a handler to the Document Loaded event and within that handler, register a handler for the Error event. Here's an example of doing that


'Hides script errors without hiding other dialog boxes.
Private Sub SuppressOnlyScriptErrors(ByVal browser As WebBrowser)
	' Ensure that ScriptErrorsSuppressed is set to false.
	browser.ScriptErrorsSuppressed = False
	
	' Handle DocumentCompleted to gain access to the Document object.
	AddHandler browser.DocumentCompleted, AddressOf browser_DocumentCompleted
End Sub



Private Sub browser_DocumentCompleted(ByVal sender As Object, ByVal e As WebBrowserDocumentCompletedEventArgs)
	AddHandler DirectCast(sender, WebBrowser).document.window.Error, AddressOf Script_Error
End Sub

Private Sub Script_Error(ByVal sender As Object, ByVal e As HtmlElementErrorEventArgs)
	' Ignore the error and suppress the error dialog box.
	e.Handled = True
End Sub



Hope this helps :)
Was This Post Helpful? 0
  • +
  • -

#3 kasbaba  Icon User is offline

  • D.I.C Head
  • PipPip

Reputation: 23
  • View blog
  • Posts: 132
  • Joined: 03-November 08


Dream Kudos: 0

Re: How to Suppress a Web-Dialog

Posted 04 November 2008 - 12:05 PM

View PostPsychoCoder, on 4 Nov, 2008 - 11:48 AM, said:

This is a known issue with the WebBrowser control in VB.NET. One thing you can do is to attach a handler to the Document Loaded event and within that handler, register a handler for the Error event. Here's an example of doing that


'Hides script errors without hiding other dialog boxes.
Private Sub SuppressOnlyScriptErrors(ByVal browser As WebBrowser)
	' Ensure that ScriptErrorsSuppressed is set to false.
	browser.ScriptErrorsSuppressed = False
	
	' Handle DocumentCompleted to gain access to the Document object.
	AddHandler browser.DocumentCompleted, AddressOf browser_DocumentCompleted
End Sub



Private Sub browser_DocumentCompleted(ByVal sender As Object, ByVal e As WebBrowserDocumentCompletedEventArgs)
	AddHandler DirectCast(sender, WebBrowser).document.window.Error, AddressOf Script_Error
End Sub

Private Sub Script_Error(ByVal sender As Object, ByVal e As HtmlElementErrorEventArgs)
	' Ignore the error and suppress the error dialog box.
	e.Handled = True
End Sub



Hope this helps :)



Hi,

thanks for replying...
tried the eventHandler, but could not suppress the web-dialog from appearing.

I have something that I wanted to try.
Probably I can read the innerHTML (documentText) as the page loads by using
Private Sub WebBrowser_ProgressChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowsera.ProgressChanged
and stop the execution of the page once I find the code for the Pop-up (web-dialog) script.
Since I saw the source of the Web-page and the script part is written at the end.
This way, I can prevent the web-dialog from appearing, since it would never get executed...

Would you suggest that I go ahead with this or is there something simpler that I can try...

kasbaba
Was This Post Helpful? 0
  • +
  • -

#4 kasbaba  Icon User is offline

  • D.I.C Head
  • PipPip

Reputation: 23
  • View blog
  • Posts: 132
  • Joined: 03-November 08


Dream Kudos: 0

Re: How to Suppress a Web-Dialog

Posted 08 November 2008 - 10:51 AM

Thanks PsychoCoder, I was able to get it working...thanks for all your help.

kababa
Was This Post Helpful? 0
  • +
  • -

#5 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • Icon

Reputation: 1401
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07


Dream Kudos: 12950

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

Re: How to Suppress a Web-Dialog

Posted 08 November 2008 - 11:03 AM

No problem, glad I could help :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1
  • You cannot start a new topic
  • Reply Reply


Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users