Hi All,
I am doing a sample VB Net Program which uses a Web Browser control. Here I am navigating to some 4-5 pages, in DocumentCompleted funtion of webBrowser Control;
Code is as follows
CODE
Private Sub WebBrowser_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser.DocumentCompleted
If PageLoaded = "LOGIN" Then
Call LoginSuccess()
ElseIf PageLoaded = "CLAIMSTATUS" Then
Call ClaimStatus()
'Thread is being Used from this state
ElseIf PageLoaded = "ENROLLEE" Then
'Thread 1 - Start After Claim Status Page is Loaded
objGetDataFromExcelThread = New Thread(AddressOf Me.GetDataFromExcel)
objGetDataFromExcelThread.Start()
ElseIf PageLoaded = "SEARCHED" Then
'Thread 2 - Starts after Searching the Patient : IIF Correct Patient is Loaded
objPatientDetailsThread = New Thread(AddressOf Me.PatientDetails)
objPatientDetailsThread.Start()
End If
End Sub
The Above code should work only after the page is completely loaded. But sometime it seems like it is loading even before the page gets completly loaded. Because of this some times i m not able to get the correct page or variable which i m using in the functions (some);
Is there any alternative to check whether the page is loaded properly ?
I tried using
CODE
Do While WebBrowser.ReadyState = WebBrowserReadyState.Interactive
Application.DoEvents()
Loop
Do While WebBrowser.ReadyState <> WebBrowserReadyState.Complete
Application.DoEvents()
Loop
But this forms an infinite loop and the page is not loaded!
------------------------------------------------------------------------------------------------------------------------------------
Someone please help me out regarding this. All I need to know is whether there is a fucntion or something like that which makes sure that the web page in web browser controll is loaded properly
Thanks and Regards
Neal Gabriel