Link to home
Start Free TrialLog in
Avatar of dibanezb
dibanezb

asked on

Webbrowser with compact framework.

This code works fine in an windows application under visual studio 2005. I need the same funcionality working in Compact Framework. I'm using PocketPC 2003.

ie is a webbrowser control.
Dim a As String
        ie.Navigate("http://www.google.com") 'or some url
        While Not ie.ReadyState = 4
            Application.DoEvents()
        End While
        a = ie.DocumentText
        MsgBox(a & a.Length) 'I need to to do something with a

Open in new window

Avatar of ChetOS82
ChetOS82
Flag of United States of America image

What isn't working exactly?  Do you get an error of some sort?  I don't think that ReadyState is available on 2003.
Avatar of dibanezb
dibanezb

ASKER

First, I receive this error:
Property 'DocumentText' is 'WriteOnly'  (This in line 'a = ie.DocumentText')
If I delete this line, I can run the program but I receive then this error:

NotSupportedException was handled
And shows this tip: "check to determine if there is a class that supports this funcionality"

This happens both, if I deploy the application to the Device (Ipaq hx 2415) or to emulator.

I ReadyState is not available, how to know if the browser ends reading? Also I need to know what the browser read.

From the .NET Compact Framework documentation at http://msdn.microsoft.com/en-us/library/ms229657.aspx

"The .NET Compact Framework does not support the Document property and its related properties and events, except for the DocumentText property. You can use DocumentText to present HTML to your users, such as to provide links and a simple HTML form, but the .NET Compact Framework does not support accessing the HTML content of a Web page with this property."

This explains why DocumentText is WriteOnly.  I cannot find a work around for this.  If you are simply trying to get the HTML code for a web site (and just using the WebBrowser control to do it), you could use the System.Net.WebClient to do the same thing.
As you say, I just try to get the HTML code for a web site. System.Net.WebClient works fine with windows but it doesn't work with Pocket PC or Windows Mobile. Any other idea?
You will have to use the System.Net.HttpWebRequest then.  It is harder to work with, but it works just as well.
Do you have an example or a link to obtain it?
ASKER CERTIFIED SOLUTION
Avatar of ChetOS82
ChetOS82
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, it works now.