Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WPF VB.NET
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
   Application.DoEvents()
Loop
 
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
''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
 
<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 10-Feb-13 21:16pm
Edited 10-Feb-13 22:59pm
v3
Comments
Sergey Alexandrovich Kryukov at 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 at 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
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
v3
Comments
Manu_vish at 11-Feb-13 3:32am
   
it is windows forms webbrowser event. i need a WPF webbrowser event
ProgramFOX at 11-Feb-13 3:41am
   
What's your code?
Manu_vish at 11-Feb-13 3:52am
   
updated the question
ProgramFOX at 11-Feb-13 3:53am
   
Thank you! Can you also provide the XAML code?
Manu_vish at 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 at 11-Feb-13 4:00am
   
Yes. Answer updated.
Manu_vish at 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 at 11-Feb-13 4:05am
   
If you want to read web page contents, have a look here:
http://www.tech-recipes.com/rx/1954/get_web_page_contents_in_code_with_csharp/
Manu_vish at 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 at 11-Feb-13 4:15am
   
streaming might not help that much.
Why might streaming not help that much?
Manu_vish at 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 at 11-Feb-13 4:22am
   
But why you don't add a web browser to your form?
Manu_vish at 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
good
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
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 341
1 Marcin Kozub 225
2 Praneet Nadkar 197
3 Sergey Alexandrovich Kryukov 190
4 Shweta N Mishra 161
0 OriginalGriff 8,149
1 Sergey Alexandrovich Kryukov 7,287
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,910


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 11 Feb 2013
Copyright © CodeProject, 1999-2014
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