473,396 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

feeding HTML in a string to the WebBrowser control

I would like to build an HTML stream as a string and have the
WebBrowser control render that HTML. Then on PostBack, or whatever it
is called, I would like my code to be the one that receives what the
WebBrowser control is sending. Effectively, my code would be the web
server and the WebBrowser control would be the web client.

All the examples I am seeing have the WebBrowser control being directed
to a URL from which to get the HTML document to render.

I have tried to set the InnerHtml property but got an error saying the
WebBrowser.Document was null. How can I set the InnerHtml of the
control without having to first set the URL property?

thanks,

-Steve

Jan 2 '07 #1
4 11970
why do you want to use the web browser control? why dont u just use the form
to provide this interface?
Jan 2 '07 #2
Have you tried to write to the browser.Document.Write(strHTML) ?

"Steve Richter" <St************@gmail.comwrote in message
news:11**********************@h40g2000cwb.googlegr oups.com...
>I would like to build an HTML stream as a string and have the
WebBrowser control render that HTML. Then on PostBack, or whatever it
is called, I would like my code to be the one that receives what the
WebBrowser control is sending. Effectively, my code would be the web
server and the WebBrowser control would be the web client.

All the examples I am seeing have the WebBrowser control being directed
to a URL from which to get the HTML document to render.

I have tried to set the InnerHtml property but got an error saying the
WebBrowser.Document was null. How can I set the InnerHtml of the
control without having to first set the URL property?

thanks,

-Steve
Jan 2 '07 #3

Ryan wrote:
Have you tried to write to the browser.Document.Write(strHTML) ?
thanks. I still got the "document is null" exception.

update:
I assigned to DocumentText and that worked!:
webBrowser1.DocumentText = "xxxx" ;

in general, how do I new up a WebBrowser.Document object?

-Steve
here is the code:

namespace demo_WebBrowser
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
webBrowser1.DocumentText = "xxxx" ;
webBrowser1.Document.Write("<h1>Hello World!</h1>");
}
private void webBrowser1_DocumentCompleted(object sender,
WebBrowserDocumentCompletedEventArgs e)
{
}
}
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.webBrowser1 = new System.Windows.Forms.WebBrowser();
this.SuspendLayout();
//
// webBrowser1
//
this.webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill;
this.webBrowser1.Location = new System.Drawing.Point(0, 0);
this.webBrowser1.MinimumSize = new System.Drawing.Size(20, 20);
this.webBrowser1.Name = "webBrowser1";
this.webBrowser1.Size = new System.Drawing.Size(827, 363);
this.webBrowser1.TabIndex = 0;
this.webBrowser1.DocumentCompleted += new
System.Windows.Forms.WebBrowserDocumentCompletedEv entHandler(this.webBrowser1_DocumentCompleted);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(827, 363);
this.Controls.Add(this.webBrowser1);
this.Name = "Form1";
this.Text = "WebBrowser Control Demo";
this.ResumeLayout(false);
}

>
"Steve Richter" <St************@gmail.comwrote in message
news:11**********************@h40g2000cwb.googlegr oups.com...
I would like to build an HTML stream as a string and have the
WebBrowser control render that HTML. Then on PostBack, or whatever it
is called, I would like my code to be the one that receives what the
WebBrowser control is sending. Effectively, my code would be the web
server and the WebBrowser control would be the web client.

All the examples I am seeing have the WebBrowser control being directed
to a URL from which to get the HTML document to render.

I have tried to set the InnerHtml property but got an error saying the
WebBrowser.Document was null. How can I set the InnerHtml of the
control without having to first set the URL property?

thanks,

-Steve
Jan 2 '07 #4

XOR wrote:
why do you want to use the web browser control? why dont u just use the form
to provide this interface?
how would I render the HTML?

thanks,

-Steve

Jan 2 '07 #5

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

Similar topics

5
by: Charles Law | last post by:
Sorry for the cross post, but I'm not sure who is best placed to answer this one. This is the most bizarre behaviour of MSHTML and streams. I have a WebBrowser control that contains nothing...
9
by: ASP .NET Newbie | last post by:
How can I run a WebBrowser control using ASP.NET/VB.NET? I know I can use the WebClient to get the page data, but I need to be able to use the WebBrowser (AxWebBrowser)? Thanks, Chad
6
by: Tiraman | last post by:
Hi, i have some html string and i would like to display it like the web browser does. what is the best way to do it ? Best Regards , Tiraman :-)
9
by: Jason Boardman | last post by:
Can anyone tell me how I can write HTML to a WebBrowser control in Visual Basic 6? I want to display HTML in the browser that is generated from within my VB program (as opposed to loading it from...
12
by: Alex Clark | last post by:
Greetings, (.NET 2.0, WinXP Pro/Server 2003, IE6 with latest service packs). I've decided to take advantage of the layout characteristics of HTML documents to simplify my printing tasks, but...
11
by: Webbert | last post by:
I am trying to display XML in a WebBrowser Control. I receive a data feed of XML and am trying to inject it into the control. I have not been successful in doing so. The only solution I have...
0
by: Balex | last post by:
hi, I have a VB.Net app which "reads" in html pages from a web server using winhttp. The purpose is for the app to "fill in" data fields on the page, then send it back to the web server, as if a...
0
by: ranjanmondal | last post by:
I can access ( read/put ) value into the textbox of an html through webbrowser control in vb ( using document.getElementById("elementName"). But some time I notice that the element(textbox) in...
0
by: overbrain | last post by:
Hello guys. I want to create a HTML on webbrowser control with zoom button. Is it possible in VB.NET?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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
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
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,...

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.