Click here to Skip to main content
13,453,725 members (44,081 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi all,
i am currently trying to use a web browser created dynamically in code to extract details in a web page. but i am unable to know when the load is complete. i know there is .LoadCompleted event.
i tried it and it is not firing for some reason. so droped it.
but i am kind of looking for the type where we used to do for winforms webbrowser control. check if the document is ready kind of like this

Do Until WebBrowser1.ReadyState = WebBrowserReadyState.Complete

is there anything similar. so that i can check and continue with the rest of the code.

''Creating the web browser dynamically
                webBrwFrst = New WebBrowser
                webBrwFrst.Navigate(New Uri(strComurl))
'''now i must check if the web page is loaded or not to continue to extract the details of the products in the webpage
''some thing like do until webbrwFrst.loaded= true then
''''Do the extraction

assuming the webpage is like Samsung or LG product web page i want al the product list in that page with there link.
so i must wait till all the images and all the details are loaded to the page

<Window x:Class="Window1"



    Title="Window1" Height="320.877" Width="588.123">
    <Grid Height="260.883">
        <Label HorizontalAlignment="Left" Margin="0,12,0,0" Name="Label1" Width="100" Height="23.139" VerticalAlignment="Top">Input Excel File:</Label>
        <TextBox  Margin="106,12,57,0" Name="txtbxFlePth" Height="23" VerticalAlignment="Top" />
        <Button HorizontalAlignment="Right" Margin="0,12.139,8,0" Name="btnBrwser" Width="43" Height="23" VerticalAlignment="Top" >Browse</Button>
        <ProgressBar Margin="15.856,115,57,121.883" Name="ProgressBar1" />
Posted 10-Feb-13 20:16pm
Updated 10-Feb-13 21:59pm
Why this Application.DoEvents? Do you know what it does? This code is a real crime! (Against yourself and your user, yes.)
Manu_vish 11-Feb-13 2:57am
ya, i know so only want to avoid it. is there any way i can check if the bowser is loaded. i just showed the code how i used to do in forms.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1


Instead of LoadCompleted, try DocumentCompleted[^].
In your comment, you said that you don't add any web browser control. I think the LoadCompleted event will only fire if you've added a web browser control on your form.

Hope this helps.
Manu_vish 11-Feb-13 3:32am
it is windows forms webbrowser event. i need a WPF webbrowser event
ProgramFOX 11-Feb-13 3:41am
What's your code?
Manu_vish 11-Feb-13 3:52am
updated the question
ProgramFOX 11-Feb-13 3:53am
Thank you! Can you also provide the XAML code?
Manu_vish 11-Feb-13 3:56am
the xml code is nothing just text boxes and the option to select the excel file from where i will get the list of URL to loop through.
I have not added any browser control if that is what you are looking for
ProgramFOX 11-Feb-13 4:00am
Yes. Answer updated.
Manu_vish 11-Feb-13 4:02am
Thanks a lot for he answer. is there no way i can do it in background. creating it dynamically and loading the webpage without being visible
ProgramFOX 11-Feb-13 4:05am
If you want to read web page contents, have a look here:
Manu_vish 11-Feb-13 4:09am
but due to some java scripts the required details are not fully loaded til the page is loaded. so i need to load the page. streaming might not help that much.
ProgramFOX 11-Feb-13 4:15am
streaming might not help that much.
Why might streaming not help that much?
Manu_vish 11-Feb-13 4:17am
i tried it. few of the products were left out. and was unable to get the full list. the java scripts loads the page dynamically. so only this webbrowser came into picture
ProgramFOX 11-Feb-13 4:22am
But why you don't add a web browser to your form?
Manu_vish 11-Feb-13 4:25am
that is last option left. thought could do it without users viewing it and giving little "Surprise" as to "WOW the data came. i think he took it directly from the server" :) :) :P
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

As discussed i didnt find any solution but have to go with making the webbrowser visible or making use of the forms webbrowser. i went with forms but the "HUGE" problem is i will have to use the doevents to get it loaded and might give error. will try it any how.
thank you very much FOX for helping on this. if any of you guys have other solution please post it. may be it will help others a lot or i only might use it

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02-2016 | 2.8.180318.3 | Last Updated 11 Feb 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100