C# Web Form Submission with WebClient Example
<p>I've read all the relevant posts on Stack Overflow and have not found something that works although I'm a novice in the web request/response programming world.</p>

<p>Problem:
I have an existing application that captures data off a web page. Simple webclient downloads page (webclient.downloadstring(url)) that parses the html and grabs relevant data. Works great. Now, I have to grab additional data off this site, but the page that has the data is a list of information that has ASP.NET JavaScript post backs that are form submits. </p>

<pre><code>&lt;a id="ctl00_ContentPlaceHolder1_GridViewSort_ctl02_LinkButton1" class="ui-btn ui-mini center noprint" href="javascript:__doPostBack(&amp;#39;ctl00$ContentPlaceHolder1$GridViewSort$ctl02$LinkButton1&amp;#39;,&amp;#39;&amp;#39;)"&gt;More Info&lt;/a&gt;
</code></pre>

<p>I have captured all the relevant input values from the initial web request form using developer tools:</p>

<pre><code>__EVENTARGUMENT: 
   __EVENTTARGET: ctl00%24ContentPlaceHolder1%24GridViewSort%24ctl03%24LinkButton1
   __EVENTVALIDATION: tpO...
   __VIEWSTATE: bI2vX...
   __VIEWSTATEENCRYPTED: 
   __VIEWSTATEGENERATOR: 5037098B
   ctl00%24ContentPlaceHolder1%24hfTicket: 0
   ctl00%24ucheader2%24m_textBoxSearch: Search%E2%80%A6
</code></pre>

<p>and have tried to mimic the post back using WebClient.UploadData(url, data) where data is converted to ascii array of byte[] as per other examples. I have also tried to capture headers and cookies, but this is where things start to fall apart. Examples I have found are not working for me.</p>

<p>Has anyone who has accomplished this please provide a code example that I can start with. I have also downloaded and tried WatIn. This may work as a temporary solution, but browser availability limitations will require far too much maintenance and intervention. I really would like to figure out how to do this with a .NET solution.</p>

<p>Thank you in advance. </p>