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