How to trigger events in an ASP.net page programmatically
<p>I have a set of pages built dynamically with controls for Data (TextBoxes, DropDowns, etc) and  two buttons for navigation (Previous and Next).</p>

<p>If I click on the 'Next' Button the form validates all the Data and if valid there's a transition to the next Page.</p>

<p>I want to invoke one of these Pages and Trigger the Next Button, submitting all the Data with a HTTP Post (http://en.csharp-online.net/HTTP_Post).</p>

<p>On the End I want to obtain the Html of the next Page.</p>

<p>I can't seem to get the 'Next Button' to be triggered with the code below. </p>

<pre><code>string url = "http://localhost/Forms/Default.aspx?FormId=b5949b04-95bc-4275-a595-8e622174fd68";
string viewstate = "/wEPDwULLTExNzY4NjMwMTgPZBYCZg9kFgICAw8WAh4HZW5jdHlwZQUTbXVsdGlwYXJ0L2Zvcm0tZGF0YRYCAgMPZBYCAgEPZBYCAgEPZBYGAgEPZBYCAgEPFgIeBFRleHQFcjx1bCBjbGFzcz0nYnJlYWRjcnVtYic+PGxpIGNsYXNzPSdDdXJyZW50Jz48YSBocmVmPScjJz5Qw6FnaW5hIDEgPC9hPjwvbGk+PGxpPjxhIGhyZWY9JyMnPlDDoWdpbmEgMiA8L2E+PC9saT48L3VsPmQCBQ9kFgICAw9kFgJmD2QWCAIBDw8WAh4HVmlzaWJsZWhkZAIDDw8WAh8CaGRkAgUPDxYCHwJoZGQCCQ8PFgIeD1ZhbGlkYXRpb25Hcm91cAUTUGFnZVZhbGlkYXRpb25Hcm91cGRkAgcPFgIfAmgWAgICD2QWAmYPZBYCAgMPDxYCHgdUb29sVGlwBX9Ow6NvIMOpIHBvc3PDrXZlbCBzdWJtZXRlciBvIGZvcm11bMOhcmlvIGVucXVhbnRvIGV4aXN0aXIgdW1hIHDDoWdpbmEgZGVzdGUgcXVlIG7Do28gc2UgZW5jb250cmEgdG90YWwvY29ycmVjdGFtZW50ZSBwcmVlbmNoaWRhZGRkHyyQApyjTI3oRHUJDqeOpQWXGng=";

        string data = "ctl00_ContentPlaceHolderMain_FormEngine_CONTROL_b34b813223d54739aa270cdc0adf57d1=100&amp;ctl00_ContentPlaceHolderMain_FormEngine_btnSubmit=clicked&amp;__VIEWSTATE=" + viewstate;
        byte[] buffer = Encoding.UTF8.GetBytes(data);
        string proxy = null;


WebRequest req = WebRequest.Create(url);

        byte[] send = Encoding.Default.GetBytes(data);
        req.Method = "POST";
        req.ContentType = "application/x-www-form-urlencoded";
        req.ContentLength = send.Length;

        Stream sout = req.GetRequestStream();
        sout.Write(send, 0, send.Length);
        sout.Flush();
        sout.Close();

        WebResponse res = req.GetResponse();
        StreamReader sr = new StreamReader(res.GetResponseStream());
        string returnvalue = sr.ReadToEnd();
</code></pre>
