I have written some code to post messages to a site. It works just fine (for the first instance), the problem is that it keeps looping (running the SendData method over and over) once it is in the webBrowser1_DocumentCompleted method. So I must not be handling the event correctly. After it has run the SendData call one time I want it return to the button1_Start_Click event from which it originally started.
private void button1_Start_Click(object sender, EventArgs e)
{
GetData();
}
private void GetData()
{
webBrowser1.Navigate(inputURLID);
}
private void SendData()
{
webBrowser1.Document.GetElementById("subject").SetAttribute("value", textBox2_Subject.Text);//To (username)
webBrowser1.Document.GetElementById("message").SetAttribute("value", richTextBox1.Text);//Subject
webBrowser1.Document.GetElementById("Submit").InvokeMember("click");//Message
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
SendData();
}