You don't need to "fill up" anything. (What it could be? :-))
Let's see. When you act as a user of a browser and fill up controls of a Web form, and then click "submit", the browser uses the data you input to create an HTTP request and sends it to the server. This request carries the parameters you input using key-value pairs; the key is the same as the attribute
name
of each input control under the form and the value is its string value.
So, all you need it to do the same thing without a browser. You should know what is the structure of the HTTP request in case of each form and send the same very request, obtain the HTTP response and then the content is this response will be the content of the "result page" you are looking for.
To do so, you need to use the class
System.Net.HttpWebRequest
:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx[
^].
Here is how you get the HTTP response:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.getresponse.aspx[
^].
Please see also my past answers:
get specific data from web page[
^],
How to get the data from another site[
^].
Now, to learn the structure of the HTTP request for the form? Apparently, by looking at the HTML source code for the forms you want to mimic, which is easily done through browser's "View Source Code" menu item (or something like that). Pay attention for controls'
name
attributes mentioned above.
The format of the key-value pairs is shown in many places. For example, see code sample (please see the first answer):
http://stackoverflow.com/questions/10263082/how-to-pass-post-parameters-to-asp-net-web-request[
^].
It would be good the debug the technique when be writing your own small ASP.NET application (which you can debug on local host using the debug HTTP server included in Visual Studio), to see how the form and its data is translated into an HTTP request, which you can test on the server side. For your working code this is not needed, I mean just the study stage, which can save you considerable time.
—SA