472,993 Members | 2,547 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,993 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 11909
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.