Archived Forum Post

Index of archived forum posts

Question:

Duplicate HTML Form Example?

Oct 24 '12 at 11:27

I'm having trouble doing a simple post to this website using c# .net 4

http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_form_method

I have tried few of your examples from your website but they all display the same message below. it should display firstname and lastname . could you please give me an example to see how you can accomplish a simple post like this. thank you.


Answer

The HTML form to be duplicated is this:

<!DOCTYPE html>
<html>
<body>

<form action="demo_form_method.asp" method="get" target="_blank"> First name: <input type="text" name="fname"><br> Last name: <input type="text" name="lname"><br> <input type="submit" value="Submit"> </form>

<p>Click on the submit button, and the input will be sent to a page on the server called "demo_form_method.asp".</p>

</body> </html>

Notice that the form tag's "method" attribute is "get". Therefore, it's not sending a POST; it's sending a GET. To duplicate this form, simply call httpObject.QuickGetStr like this:

(in pseudo-code)
htmlStr = httpObject.QuickGetStr("http://www.w3schools.com/tags/demo_form_method.asp?fname=John&lname=Smith"