WebBrowser.DocumentText being set stays on about:blank sometimes

Z

Zytan

I have a WebBroswer control, and I set the HTML it will display via
DocumentText, which takes a a string. This shows the HTML code from
the string in the control. But, sometimes, the WebBrowser shows
nothing. Clicking 'view source' shows: "<HTML></HTML>", and the
filename is called "about_blank[1].txt", which is the about:blank URL.

I am aware that when you set this property, the WebBrowser control
automatically navigates to the about:blank URL before loading the
specified text. And that means that the Navigating, Navigated, and
DocumentCompleted events occur when you set this property.

So, for some reason, and only sometimes, the WebBrowser STAYS on
about:blank. Should I handle the events and do something with them to
kick this in the ass and move it forward to actually displaying the
content I am passing it?

Note that adding more HTML to the SAME string and then setting
DocumentText to this will then show the HTML. So, it's finnicky when
it works and doesn't (but, it is consistent on when it does and
doesn't work).

Zytan
 
Z

Zytan

I guess I am not the only one who has noticed this. It's been
suggested that a "much more elegant and effective way of populating
web browser control with html is to use Write method of Document
object of WebBrowser control".

But, what if the Document object is null? What do I do then? How do
I get to the point of where I can call the Write method within it?

Zytan
 
Z

Zytan

So, for some reason, and only sometimes, the WebBrowser STAYS on
about:blank.

http://neovolve.com/archive/2006/02/12/684.aspx

"If you fire up reflector and find the WebBrowser.DocumentText
property you will see ... it will attempt to navigate to about:blank
as the documentation says. The code here indicates that the stream
data will be populated into the browser after it has navigated to
about:blank. The hitch here is that if the navigation fails, you are
none the wiser that the process has failed and the new document text
won't be loaded. My problem with the code here is that the try block
around the navigate swallows the exception, hence the document content
doesn't change and you won't know why."

Zytan
 

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