auto submit a form on an asp.net page

Zelter Ady picture Zelter Ady · Feb 28, 2012 · Viewed 12.2k times · Source

I want to make an application (in .Net) that fills and submits a form (in an asp.net website).

This applications should read the page, find the fields (inputs), extract name/id of the fields I want to fill it in and submit the page to the server.

I don't want an app that holds an webbrowser control and automate the navigation on it!

What I have: I have the part that download the html, I have the part that finds the fields and extract their names/ids.

What I need: A way to submit the form to the server (POST, not GET).

On the html of the page the submission is done by javascript, something like this:

javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("Button1", "", true, "", "", false, false))

The question is: how to submit in this case?

Answer

Diego Garcia picture Diego Garcia · Feb 28, 2012

You can just submit using the javascript:

<script type="text/javascript">
  document.forms["your_form_id"].submit();
</script>