is it possibe to post html from vb.net

A

andy

Hi


I have a requirement to submit form data to a url after collecting the
data from the database.
For example I need to send firstname and lastname through a post method

I can call on the fly.


This is the traditional route below , I want to emulate this submit
action from a vb.class using request.method="post"
<FORM action="http://somesite.com/prog/adduser" method="post">
First name: <INPUT type="text" name="firstname"><BR>
Last name: <INPUT type="text" name="lastname"><BR>
email: <INPUT type="text" name="email"><BR>
<INPUT type="submit" value="Send"> <INPUT type="reset">
</FORM>


clear as mud?
Anyone have any tips ?
 
G

Gary Townsend

THis would be something similar to what you are looking for..if anyone sees
any mistakes feel free to chime in.

Public Sub SubmitForAndy
Dim formData As String
Dim uri As Uri

uri = New Uri(txtAddress.Text)
Dim httpReq As HttpWebRequest = DirectCast(WebRequest.Create(uri),
HttpWebRequest)

formData = "username=" & txtUsername.Text & "&password=" &
txtPassword.Text
httpReq.AllowAutoRedirect = True
httpReq.Method = "POST"
httpReq.ContentType = "application/x-www-form-urlencoded()"
httpReq.ContentLength = formData.Length

Dim sw As New StreamWriter(httpReq.GetRequestStream)
sw.Write(formData)
sw.Close()
End Sub



Gary Townsend.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top