Welcome to Dream.In.Code
Become an Expert!

Join 150,411 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 956 people online right now. Registration is fast and FREE... Join Now!




Web browser control CocumentCompleted

 
Reply to this topicStart new topic

Web browser control CocumentCompleted, Problem after Document Completed function invokes

nealgabriel45
31 Mar, 2008 - 06:04 AM
Post #1

New D.I.C Head
Group Icon

Joined: 22 Oct, 2007
Posts: 46


Dream Kudos: 50
My Contributions
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

User is offlineProfile CardPM
+Quote Post

ruimacdonald
RE: Web Browser Control CocumentCompleted
30 Dec, 2008 - 02:58 AM
Post #2

New D.I.C Head
*

Joined: 30 Dec, 2008
Posts: 1


My Contributions
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.gif

QUOTE(nealgabriel45 @ 31 Mar, 2008 - 06: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
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


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 07:38PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month