Send Post request programmatically with passing values
<p>I have app with 1 page "Default.aspx".
At the page I have Textbox with ID="tbx" and Button with Click event handler after postback which reads Text property from Textbox, saves this value in the Session.</p>

<p>Now I want to implement auto sending post request with raising Button click and passing some text as Textbox value.</p>

<p>How to implement this?</p>

<p>Now I can do next, but I can't call Button click event</p>

<pre><code> protected void Button1_Click(object sender, EventArgs e)
        {
            HttpWebRequest myHttpWebRequest = (HttpWebRequest)HttpWebRequest.Create("http://localhost.:49950/Default.aspx");
            //  myHttpWebRequest.Proxy = new WebProxy("localhost", 8888);
            myHttpWebRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1;)";
            myHttpWebRequest.Accept = "image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, " +
                                       "application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*";
            myHttpWebRequest.Headers.Add("Accept-Language", "en-US");

            HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
            string sCookies = String.IsNullOrEmpty(myHttpWebResponse.Headers["Set-Cookie"]) ? "" : myHttpWebResponse.Headers["Set-Cookie"];


             DoPostback(sCookies );

        }

        private void DoPostback(string sCookies)
        {
            HttpWebRequest myHttpWebRequest = (HttpWebRequest)HttpWebRequest.Create("http://localhost.:49950/Default.aspx");

            myHttpWebRequest.Method = "POST";
            myHttpWebRequest.Referer = "http://localhost.:49950/Default.aspx";
            myHttpWebRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1;)";
            myHttpWebRequest.Accept = "image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, " +
                                       "application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*";
            myHttpWebRequest.Headers.Add("Accept-Language", "en-US");
            myHttpWebRequest.ContentType = "application/x-www-form-urlencoded";
            if (!String.IsNullOrEmpty(sCookies))
                myHttpWebRequest.Headers.Add(HttpRequestHeader.Cookie, sCookies);

            myHttpWebRequest.AllowAutoRedirect = false;          
        }
</code></pre>
