VB.NET 2005 Express WebBrowser Control

S

Scott Gravenhorst

I recently (within 30 days) downloaded and installed VB 2005 Express.
I like it a whole lot... but:

I have been trying to work with the WebBrowser control to display a
small amount of help text for my application and though I've finally
made it work, it seems a bit quirky, so perhaps that's the control
being quirky or perhaps there is something I don't understand.

1) I could not figure out a way to make the webbrowser object display
a page of HTML from a file on the local disk in the same directory as
the application. I tried setting the Url property to file:///help.htm
and file://help.htm and neither worked. help.htm was in the
applications directory. -- Is that were it should exist? I would
prefer to use the control with a local file, but read on...

2) I then found that I could stuff text into the
WebBrowser.DocumentText property and alas - the page was displayed
(that is, the page of text that I stuffed into the property, not the
page as described by the Url property).

3) I cleaned up the object by removing the text in the Url property -
this broke it and the WebBrowser object displayed nothing, even though
I stuffed the DocumentText property.

4) I tried setting the Url property to about:blank, still the object
displayed nothing.

5) Then I found that as long as there is something like http://x in
the Url propertly, the webbrowserobject will display the HTML I stuff
into the DocumentText property. This is true, even if the page
referred to by the Url property does not exist. -- so why doesn't
using about:blank work?

Also, the AllowNavigation property must be set to true or this won't
work.

I've looked on various web forums and while I can see that others have
had a similar problem, I haven't seen any solution that makes sense or
simply declares the current object is buggy.

Help/advice/condolences greatly appreciated.
 
Y

Yet Another One

I recently (within 30 days) downloaded and installed VB 2005 Express.
I like it a whole lot... but:

I have been trying to work with the WebBrowser control to display a
small amount of help text for my application and though I've finally
made it work, it seems a bit quirky, so perhaps that's the control
being quirky or perhaps there is something I don't understand.

1) I could not figure out a way to make the webbrowser object display
a page of HTML from a file on the local disk in the same directory as
the application. I tried setting the Url property to file:///help.htm
and file://help.htm and neither worked. help.htm was in the
applications directory. -- Is that were it should exist? I would
prefer to use the control with a local file, but read on...

2) I then found that I could stuff text into the
WebBrowser.DocumentText property and alas - the page was displayed
(that is, the page of text that I stuffed into the property, not the
page as described by the Url property).

3) I cleaned up the object by removing the text in the Url property -
this broke it and the WebBrowser object displayed nothing, even though
I stuffed the DocumentText property.

4) I tried setting the Url property to about:blank, still the object
displayed nothing.

5) Then I found that as long as there is something like http://x in
the Url propertly, the webbrowserobject will display the HTML I stuff
into the DocumentText property. This is true, even if the page
referred to by the Url property does not exist. -- so why doesn't
using about:blank work?

Also, the AllowNavigation property must be set to true or this won't
work.

I've looked on various web forums and while I can see that others have
had a similar problem, I haven't seen any solution that makes sense or
simply declares the current object is buggy.

Help/advice/condolences greatly appreciated.


WebBrowser1.Url = New System.Uri("file:///" & Application.StartupPath
& "/help.html")

This works for me. Try it out, let me know if it helps any.

Ryan
 
S

Scott Gravenhorst

WebBrowser1.Url = New System.Uri("file:///" & Application.StartupPath
& "/help.html")

This works for me. Try it out, let me know if it helps any.

Ryan

Thank you Ryan, that does in fact work. I didn't realize I needed to
specify the startup directory - that makes sense, but out of
curiousity, I still would like to know why I can't leave the Url
property blank and simply stuff the DocumentText property and have the
object display the data... ?? It _will_ display the stuffed HTML if
I put anything basically legal in the Url property, regardless of
whether the page exists or not.

P.S., yes, I am having a beer, but no, I am not yet drunk... (c;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top