Peter Duniho said:
Works fine for me. Post the code that doesn't work. And be more
explicit about what "load the webBrowser.Document property or window"
means, as well as exactly what "it fails" means (including any error
message, if there is one).
Pete
Thanks Pete,
The com visibility is for other features not listed.
If I navigate to the URL in the Form1_Load method, it works.
But if I navigate to the URL in the button1_Click method, it does not
works.
Error massage states that the webBrowser1.Document object is null.
I'm assuming that the webBrowser1.Navigate("
http://msdn.microsoft.com")
method call loads the webBrowser1 control properties.
The none functioning code is as follows:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Diagnostics;
namespace Apartment_Listing
{
[ComVisible(true)]
public partial class Form1 : Form
{
string Apartments;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//webBrowser1.Navigate("
http://msdn.microsoft.com");
}
private void button1_Click(object sender, System.EventArgs e)
{
string htmlOut = null;
webBrowser1.Navigate("
http://msdn.microsoft.com");
while (webBrowser1.IsBusy) System.Threading.Thread.Sleep(500);
this.Text = webBrowser1.Document.Title;
ProcessPage(webBrowser1.Document, ref htmlOut);
webBrowser2.DocumentText = htmlOut;
}
private void ProcessPage(HtmlDocument doc, ref string htmlOut)
{
htmlOut += "<br />New Page<br />";
while (webBrowser1.IsBusy) System.Threading.Thread.Sleep(1000);
// Deleted for brevity...
}
private void webBrowser1_DocumentCompleted(object sender,
WebBrowserDocumentCompletedEventArgs e)
{
}
Thanks,
King