Web browser control CocumentCompleted

Problem after Document Completed function invokes

Page 1 of 1

2 Replies - 8407 Views - Last Post: 24 March 2009 - 02:24 AM Rate Topic: -----

#1 nealgabriel45  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 4
  • View blog
  • Posts: 46
  • Joined: 22-October 07

Web browser control CocumentCompleted

Posted 31 March 2008 - 07:04 AM

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
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

		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

Is This A Good Question/Topic? 0
  • +

Replies To: Web browser control CocumentCompleted

#2 ruimacdonald  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 30-December 08

Re: Web browser control CocumentCompleted

Posted 30 December 2008 - 03:58 AM

Hi

I'm having the same problem. How the hell can we know that the Webbrowser.Document is really completed????

Did you find any answer?

Regards

Rui Macdonald :wub:

View Postnealgabriel45, on 31 Mar, 2008 - 06:04 AM, said:

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
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

		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

Was This Post Helpful? 0
  • +
  • -

#3 fakharak  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 24-March 09

Re: Web browser control CocumentCompleted

Posted 24 March 2009 - 02:24 AM

View Postruimacdonald, on 30 Dec, 2008 - 02:58 AM, said:

Hi

I'm having the same problem. How the hell can we know that the Webbrowser.Document is really completed????

Did you find any answer?

Regards

Rui Macdonald :wub:

View Postnealgabriel45, on 31 Mar, 2008 - 06:04 AM, said:

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
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

		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



Read it carefully, this is solution for VB, but unfotunately i am unable to find how to do this in C#.NET

http://support.micro...com/kb/q180366/

Moreover, it seems that the DocumentComplete is also fired when a Object in a document starts downloading. Like an "Image as Object". I see that when the first page after i log in http:mail.yahoo.com starts loading.

Anyways, above URL will surely help you. And if you find C#.NET version then please help me.
Regards

View Postfakharak, on 24 Mar, 2009 - 01:20 AM, said:

View Postruimacdonald, on 30 Dec, 2008 - 02:58 AM, said:

Hi

I'm having the same problem. How the hell can we know that the Webbrowser.Document is really completed????

Did you find any answer?

Regards

Rui Macdonald :wub:

View Postnealgabriel45, on 31 Mar, 2008 - 06:04 AM, said:

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
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

		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

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1