setting html code in axwebbrowser

D

Dan

I'd like to display some HTML code in a form using the axwebbrowser control,
without having to create a temporary file to navigate to. I'm trying the
following code (let's say that the web browser control is named wbb):

object o = System.Reflection.Missing.Value;
wbb.Navigate("about:blank", ref o, ref o, ref o, ref o);
while (wbb == null) Application.DoEvents();
mshtml.HTMLDocument doc = (mshtml.HTMLDocument)wbb.Document;
doc.body.innerHTML = "...(my html code)...";

here the last line of code throws an exception as doc.body is null, even if
I have forced the control to navigate to the blank page to avoid this.
What's the correct way of setting the HTML code of a webbrowser control?

Thanks guys!
 
R

Robert Jordan

Hi Dan,
I'd like to display some HTML code in a form using the axwebbrowser control,
without having to create a temporary file to navigate to. I'm trying the
following code (let's say that the web browser control is named wbb):

object o = System.Reflection.Missing.Value;
wbb.Navigate("about:blank", ref o, ref o, ref o, ref o);
while (wbb == null) Application.DoEvents();

wbb is never "null". Use wbb.Document or see Nirosh's answer.

bye
Rob
 

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