views:

52

answers:

1

I have a WebBrowser Control in my VB.NET application. Now the it browses through many URLs (may be 10 - 20) and I want that each of the page HTML saved in text file. Now the thing is that when I write the HTML of page in file, it does not write the HTML of current page rather than the initial one because it calls the event before even the page is loaded.

How can I wait until the page is completely loaded before calling any event?

I tried the following code but it doesn't works.

Do Until WebBrowser1.ReadyState = WebBrowserReadyState.Complete
   Application.DoEvents()
Loop
+2  A: 

Sounds like you want to catch the DocumentCompleted event of your webbrowser control.

MSDN has a couple of good articles about the webbrowser control - WebBrowser Class has lots of examples, and How to: Add Web Browser Capabilities to a Windows Forms Application

Dan F
In the declaration of WebBrowser itself I am using Private Sub WebBrowser1_DocumentCompletedHow Can I implement what to happen when page is fully loaded inside the declarion of webbrowser?
Shubham
@Shubham: http://msdn.microsoft.com/en-us/library/k2kt7a7y.aspx (MSDN: "How to: Write Event Handlers"), or have a look at Hans' example. Don't forget the `Handles` keyword at the end of the method declaration.
Heinzi