I have written some code to post messages to a site. It works just fine when I run it with button clicks, but if I try to run the whole thing with one single shot it throws an error. I know that the problem is that when I try to run it all in one shot the WebBrowser is not loading the page totally and thus it can't post the data. I know this is an easy fix, but I am stumped.
private void button1_Start_Click(object sender, EventArgs e)//this is just the Pseudocode
{
GetData();
SendData();//If I eliminate this and just fire the SendData method with a button click, program works fine
}
private void GetData()
{
webBrowser1.Navigate(inputURLID);
}
private void SendData()//if I replace this with button2_Post_Click it works fine
{
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)
{
}