i have converted this vb code into c# , i got this code from this link http://aspnetlibrary.com/articledetails.aspx?article=Retrieve-data-from-a-web-page, this is post method() code....
Then where i want to write this code in web form submit button... ah ? i want to give 3textbox input and give search, i want output from this website
http://www.ticketgoose.com/ search....
Imports System.IO
Imports System.Net
Partial Class Default1
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strURL As String = ""
Dim strPostData As String = ""
Dim strResult As String = ""
Dim wbrq As HttpWebRequest
Dim wbrs As HttpWebResponse
Dim sw As StreamWriter
Dim sr As StreamReader
' Set the URL to post to
strURL = "http://www.webcom.com/cgi-bin/form"
' Post some values to the page
strPostData = String.Format("your_name={0}&userid={1}&form_name={2}", "Mark Smith", "webcom", "tutortest")
' Create the web request
wbrq = WebRequest.Create(strURL)
wbrq.Method = "POST"
' We don't always need to set the Referer but in this case
' the page we are posting to will only issue a response if we do
wbrq.Referer = "http://www.webcom.com/cgi-bin/form"
wbrq.ContentLength = strPostData.Length
wbrq.ContentType = "application/x-www-form-urlencoded"
' Post the data
sw = New StreamWriter(wbrq.GetRequestStream)
sw.Write(strPostData)
sw.Close()
' Read the returned data
wbrs = wbrq.GetResponse
sr = New StreamReader(wbrs.GetResponseStream)
strResult = sr.ReadToEnd.Trim
sr.Close()
' Write the returned data out to the page
TextBox1.Text = strResult
End Sub
End Class
maddyrafi897...
Member
134 Points
300 Posts
Re: try to help
Apr 30, 2012 05:26 AM|LINK
i have converted this vb code into c# , i got this code from this link http://aspnetlibrary.com/articledetails.aspx?article=Retrieve-data-from-a-web-page, this is post method() code....
Then where i want to write this code in web form submit button... ah ? i want to give 3textbox input and give search, i want output from this website http://www.ticketgoose.com/ search....
Imports System.IO
Imports System.Net
Partial Class Default1
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strURL As String = ""
Dim strPostData As String = ""
Dim strResult As String = ""
Dim wbrq As HttpWebRequest
Dim wbrs As HttpWebResponse
Dim sw As StreamWriter
Dim sr As StreamReader
' Set the URL to post to
strURL = "http://www.webcom.com/cgi-bin/form"
' Post some values to the page
strPostData = String.Format("your_name={0}&userid={1}&form_name={2}", "Mark Smith", "webcom", "tutortest")
' Create the web request
wbrq = WebRequest.Create(strURL)
wbrq.Method = "POST"
' We don't always need to set the Referer but in this case
' the page we are posting to will only issue a response if we do
wbrq.Referer = "http://www.webcom.com/cgi-bin/form"
wbrq.ContentLength = strPostData.Length
wbrq.ContentType = "application/x-www-form-urlencoded"
' Post the data
sw = New StreamWriter(wbrq.GetRequestStream)
sw.Write(strPostData)
sw.Close()
' Read the returned data
wbrs = wbrq.GetResponse
sr = New StreamReader(wbrs.GetResponseStream)
strResult = sr.ReadToEnd.Trim
sr.Close()
' Write the returned data out to the page
TextBox1.Text = strResult
End Sub
End Class