I can not fix the error anyone can help me? ..
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;
namespace test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
webBrowser1.Navigate(" http://www.httpsurf.com/ ");
//the debugger tells me that the error in this line
webBrowser1.Document.GetElementById("url").InnerText = textBox1.Text;
webBrowser1.Document.GetElementById("go").InvokeMember("Click");
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
Loading
Sam HobbsPosted Nov 12, 2011, 12:20 AM
Second, please see my article Introduction to Web Site Scraping.
Javeed M ShaikhPosted Nov 11, 2011, 2:49 PM
webBrowser1.Navigate(" http://www.httpsurf.com/ ");
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
// here is the event
void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
webBrowser1.Document.GetElementById("Url").InnerText = textBox1.Text;
}
Posted Nov 11, 2011, 2:09 PM
Jean PaulPosted Nov 11, 2011, 1:46 PM
Following is the corrected code.
Please note that you have to ensure the event is not called multiple times (delegate, invoking click)
VulpesPosted Nov 11, 2011, 1:46 PM
To prevent the exception, you'd therefore need to do this:
if (webBrowser1.Document.GetElementById("url") != null)
{
}