Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
1.00/5 (1 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

VB
Do Until WebBrowser1.ReadyState = WebBrowserReadyState.Complete
   Application.DoEvents()
Loop


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

VB
''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
''loop


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

XML
<Window x:Class="Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    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" />
        
    </Grid>
</Window>
Posted
Updated 10-Feb-13 21:59pm
v3
Comments
Sergey Alexandrovich Kryukov 11-Feb-13 2:21am    
Why this Application.DoEvents? Do you know what it does? This code is a real crime! (Against yourself and your user, yes.)
—SA
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.

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
 
Share this answer
 
Hi,

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.
 
Share this answer
 
v3
Comments
Manu_vish 11-Feb-13 3:32am    
it is windows forms webbrowser event. i need a WPF webbrowser event
Thomas Daniels 11-Feb-13 3:41am    
What's your code?
Manu_vish 11-Feb-13 3:52am    
updated the question
Thomas Daniels 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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900