Gleat, thanks again for your program. The only thing that is different in the situation I described is that the postdata values are not known when the program is run. You gave me the info I needed to look that up so all is good. For the benefit of any one else who is trying to do this: Download a program called Fiddler from www.fiddler2.com. Open fiddler then use your web browser to click the elements on the page you are trying to automate. Observe the data posted back to the server. The ParseDocument function you write (see code below) will need to create a string that matches the postdata. Here is the code you can run to automate your page. Create a form with a textbox and a button. Paste the code below as the form class. The ParseDocument function is specific for my purpose. I included it to demonstrate the basic foreach loop and id test.
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void Form3_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
try
{
// Create a web request for the initital query to get post values
string url = textBox1.Text;
IHTMLDocument2 doc = new HTMLDocumentClass();
WebRequest request1 = WebRequest.Create(url);
WebResponse response1 = request1.GetResponse();
StreamReader reader = new StreamReader(response1.GetResponseStream());
doc.write(reader.ReadToEnd());
doc.close();
response1.Close();
// Loop through the html document elements to get postdata values
string postdata = ParseDocument(doc);
//
// create a web request for our page
//
WebRequest request = WebRequest.Create(url);
request.ContentType = "application/x-www-form-urlencoded";
request.Method = "POST";
((HttpWebRequest)request).Referer = url;
//
// write the post data
//
using (Stream stream = request.GetRequestStream())
{
stream.Write(Encoding.UTF8.GetBytes(postdata), 0, Encoding.UTF8.GetByteCount(postdata));
stream.Flush();