Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - How to copy text from webbrowser/Frame Control (WPF)

Reply
 
Old 08-06-2009   #1 (permalink)
claton


 
 

How to copy text from webbrowser/Frame Control (WPF)

Hello,

I've added a webbroswer control in my WPF application, As the app loads up,
it naviagates to a site then How do I copy text from the site using code. I
can successfully do this in WinForms using WebBrowser1.Document.DomDocument
not able to do the same in WPF webbrowser control.
Any tips.

Thanks in Advance!

Regards,
Claton



My System SpecsSystem Spec
Old 08-07-2009   #2 (permalink)
Bjarte Skogøy


 
 

Re: How to copy text from webbrowser/Frame Control (WPF)

The document should be available in the WebBrowser object. There's a
property named Document.
http://msdn.microsoft.com/en-us/libr...r_members.aspx


--
regards
Bjarte Skogøy

"claton" <claton@xxxxxx> skrev i nyhetsmeldingen:
BE05FA45-B854-4032-8524-2CCF499CA176@xxxxxx ...
Quote:

> Hello,
>
> I've added a webbroswer control in my WPF application, As the app loads
> up,
> it naviagates to a site then How do I copy text from the site using code.
> I
> can successfully do this in WinForms using
> WebBrowser1.Document.DomDocument
> not able to do the same in WPF webbrowser control.
> Any tips.
>
> Thanks in Advance!
>
> Regards,
> Claton
>
>
My System SpecsSystem Spec
Old 08-07-2009   #3 (permalink)
claton


 
 

Re: How to copy text from webbrowser/Frame Control (WPF)

Thank you Bjarte for replying,
I have checked the msdn and the property document is a bit different than
the WinForm WebBrowser. I have the following code in Winform

Public Class Form1
Dim doc As mshtml.HTMLDocument
Dim txtRange As mshtml.IHTMLTxtRange
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("www.microsoft.com")
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
txtRange = doc.selection.createRange()
MessageBox.Show(txtRange.text.ToString())
End Sub

Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal
e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles
WebBrowser1.DocumentCompleted
doc = Me.WebBrowser1.Document.DomDocument
End Sub
End Class
------------------
but when I try to use the WPF webbrowser it does not have extented
properties to the Document just like the winForm Document.DomDocument.

- Claton

"Bjarte Skogøy" wrote:
Quote:

> The document should be available in the WebBrowser object. There's a
> property named Document.
> http://msdn.microsoft.com/en-us/libr...r_members.aspx
>
>
> --
> regards
> Bjarte Skogøy
>
> "claton" <claton@xxxxxx> skrev i nyhetsmeldingen:
> BE05FA45-B854-4032-8524-2CCF499CA176@xxxxxx ...
Quote:

> > Hello,
> >
> > I've added a webbroswer control in my WPF application, As the app loads
> > up,
> > it naviagates to a site then How do I copy text from the site using code.
> > I
> > can successfully do this in WinForms using
> > WebBrowser1.Document.DomDocument
> > not able to do the same in WPF webbrowser control.
> > Any tips.
> >
> > Thanks in Advance!
> >
> > Regards,
> > Claton
> >
> >
>
My System SpecsSystem Spec
Old 08-07-2009   #4 (permalink)
claton


 
 

Re: How to copy text from webbrowser/Frame Control (WPF)

okie! I found the answer here
http://www.rhizohm.net/irhetoric/blog/72/default.aspx

you need to type cast MSHTML to the webbrowser.document so access the
contents/text on the navigated URL.

Hope this helps others too..

~ Claton

"claton" wrote:
Quote:

> Thank you Bjarte for replying,
> I have checked the msdn and the property document is a bit different than
> the WinForm WebBrowser. I have the following code in Winform
>
> Public Class Form1
> Dim doc As mshtml.HTMLDocument
> Dim txtRange As mshtml.IHTMLTxtRange
> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> WebBrowser1.Navigate("www.microsoft.com")
> End Sub
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> txtRange = doc.selection.createRange()
> MessageBox.Show(txtRange.text.ToString())
> End Sub
>
> Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal
> e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles
> WebBrowser1.DocumentCompleted
> doc = Me.WebBrowser1.Document.DomDocument
> End Sub
> End Class
> ------------------
> but when I try to use the WPF webbrowser it does not have extented
> properties to the Document just like the winForm Document.DomDocument.
>
> - Claton
>
> "Bjarte Skogøy" wrote:
>
Quote:

> > The document should be available in the WebBrowser object. There's a
> > property named Document.
> > http://msdn.microsoft.com/en-us/libr...r_members.aspx
> >
> >
> > --
> > regards
> > Bjarte Skogøy
> >
> > "claton" <claton@xxxxxx> skrev i nyhetsmeldingen:
> > BE05FA45-B854-4032-8524-2CCF499CA176@xxxxxx ...
Quote:

> > > Hello,
> > >
> > > I've added a webbroswer control in my WPF application, As the app loads
> > > up,
> > > it naviagates to a site then How do I copy text from the site using code.
> > > I
> > > can successfully do this in WinForms using
> > > WebBrowser1.Document.DomDocument
> > > not able to do the same in WPF webbrowser control.
> > > Any tips.
> > >
> > > Thanks in Advance!
> > >
> > > Regards,
> > > Claton
> > >
> > >
> >
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
How do I debug JavaScript in a WebBrowser control? .NET General
automating ie or webbrowser control VB Script
is the dotnet 2 webbrowser control based on IE 6 or 7? .NET General
Printint the content of a webbrowser control .NET General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46