Click to See Complete Forum and Search --> : Posting data to a form


MMH
September 25th, 2008, 01:52 PM
Hello All,

There is one website which validates email address (checks whether email address exists or not)

There is a form, having an input field (textbox) and a submit button.
I want to post data to this form from my application (it would be in ASP.net) and get the responce. (On this page, result is displayed in the label)

How can i achieve this ?

Thanks
MMH

mmetzger
September 26th, 2008, 07:24 AM
It varies a little based on the version of the framework you're using, but look at the WebClient libraries. Basically, you can make the call to the appropriate page (Look at the destination of the form from the page source) and POST the appropriate variables. Depending on the format that you get back you may need to run a RegEx or something similar to filter down to the specific data you want to display.

MMH
September 26th, 2008, 08:56 AM
Thanks for the reply, Basically i am using WebHttpRequest and WebHttpResponce to deal with this.
But the main question is that, how do i post the value to a form ?

Let me explain this:

There is a website (tht i do not own) which has a form having 1 textbox and 1 button.
in normal case, user would enter some value in textbox and click button. But i want to post value to that form from my application (ASP.NET).

Also, there is a label which shows the status whehter the submissions was proper or not.
So i know i can parse that label value from the responce i get. But the problem is in posting data.

Thanks again.
MMH

mmetzger
September 26th, 2008, 09:28 AM
Yeah, we're on the same page -

Look at the WebClient class - this gives some more options. Basically, look at this page: http://msdn.microsoft.com/en-us/library/ms144244.aspx. This references the UploadValues option in the WebClient that will allow you to pass a URI, the method to use (a POST in this case), and a NameValueCollection. The NVC will contain all the info you want to pass along, in other words, the form fields. You can look at the page source to determine exactly what the field names are and fill them out accordingly.

The minor irritation here is this will give you back a byte array so you'll have to process the output accordingly. You may be able to convert the byte array into a Response object and go from there.

Hope this helps -