Curtis
Curtis

Reputation: 103338

POST a HTML Form programmatically?

I need to POST a HTML form to a 3rd party website (a Mass-SMS texting system).

In the past I've done this by forwarding to a page containing a form I've pre-populated and hidden (using display:none), then I've ran a javascript function at the end of the page to automatically submit this form.

However I'm hoping theres someway I can do all this programmatically (as I don't care about the response, and the user doesn't need to see the page the form is being posted to).

How can I do this? Cheers

Upvotes: 1

Views: 8226

Answers (2)

mrbellek
mrbellek

Reputation: 2300

If you're willing to get into PHP, you can very easily use cURL for this. Otherwise it's going to be quite difficult using just Javascript.

See here for a detailed tutorial.

Upvotes: 0

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

You could use a WebClient.UploadValues method to send an HTTP POST request to a remote server from your code behind. Just fill up the name/value collection with the values coming from the hidden fields.

Upvotes: 5

Related Questions