471,595 Members | 2,233 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,595 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 11766
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by ASP .NET Newbie | last post: by
9 posts views Thread by Jason Boardman | last post: by
12 posts views Thread by Alex Clark | last post: by
11 posts views Thread by Webbert | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

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.