473,511 Members | 12,747 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

setting html code in axwebbrowser

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!
Nov 16 '05 #1
2 1829
Try to write the code in DocumentComplete Event

Nirosh.

"Dan" <df***@hotmail.com> wrote in message
news:O8**************@TK2MSFTNGP10.phx.gbl...
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!

Nov 16 '05 #2
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
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2914
by: panik | last post by:
Hi, retreiving the source code from an instance of the AxWebBrowser component, using getBody(), through an IHTMLDocument2 object, makes the sourcode look very bad: All tags are in uppercase,...
27
8327
by: Michael C | last post by:
Anyone know of a good HTML Rendering control? I need a control that will render and display HTML in a Windows form. It doesn't need to pull down HTML pages from the Web - I'll feed it all the...
0
1313
by: thompson_38 | last post by:
What is the difference between calling a HTML page stored on the local machine (axWebBrowser.Navigate("home.htm" ref 0, ref 0, ref 0, ref 0)) and being able to access a frame, to creating a...
0
264
by: thompson_38 | last post by:
What is the difference between calling a HTML page stored on the local machine (axWebBrowser.Navigate("home.htm" ref 0, ref 0, ref 0, ref 0)) and being able to access a frame, to creating a...
0
7430
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7089
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7517
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5673
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5072
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3217
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
790
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
451
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.