Post Data from page to another (BOA page) in vb.net 
Author Message
 Post Data from page to another (BOA page) in vb.net

Below is test code to try to post from one page to another.  I'm not  able
to request the values for the variables txtName, txtAddress, or txtBox.

I don't know what I am doing wrong.  I need to be able to post data that I
retrieve from a ASPX form to a Bank Of America site.  That's the only way I
can get my accounts updated.  Anybody who has this similar situation or
information, please get back to me.


Imports System

Imports System.Net

Imports System.IO

Imports System.Text

Public Class Main

Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.De{*filter*}StepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

Dim strPost, strPosted As String

Protected WithEvents txtName As System.Web.UI.WebControls.TextBox

Protected WithEvents Label1 As System.Web.UI.WebControls.Label

Protected WithEvents Label2 As System.Web.UI.WebControls.Label

Protected WithEvents btnTest As System.Web.UI.WebControls.Button

Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox

Protected WithEvents txtAddress As System.Web.UI.WebControls.TextBox

Function readHtmlPage(ByVal url As String) As String

Dim objResponse As WebResponse

Dim objRequest As WebRequest

Dim result As String

objRequest = System.Net.HttpWebRequest.Create(url)

objRequest.ContentType = "application/x-www-form-urlencoded"

' objResponse = objRequest.GetResponse()

objResponse = CType(objRequest.GetResponse(), HttpWebResponse)

Dim sr As New StreamReader(objResponse.GetResponseStream())

result = sr.ReadToEnd()

'clean up StreamReader

sr.Close()

Return result

End Function

Function PostHtmlPage(ByVal strPost As String, ByVal url As String) As
String

Dim result As String = ""

Dim myWriter As StreamWriter

Dim objRequest As HttpWebRequest = WebRequest.Create(url)

objRequest.Method = "POST"

objRequest.ContentLength = strPost.Length

objRequest.ContentType = "application/x-www-form-urlencoded"

Try

myWriter = New StreamWriter(objRequest.GetRequestStream())

myWriter.Write(strPost)

Catch e As Exception

Return e.Message

Finally

myWriter.Close()

End Try

Return result

End Function

Private Sub btnTest_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnTest.Click

Dim s As StringBuilder = New StringBuilder()

Dim tmpstr As String

tmpstr = "<input type='Hidden' Name='Test1' Value='" & txtName.Text & "'>"

s.Append(tmpstr)

tmpstr = "<Name='TxtName' Value='" & txtName.Text & "'>"

s.Append(tmpstr)

strPost = readHtmlPage(" http://www.*-*-*.com/ ;)

strPosted = PostHtmlPage(strPost,
" http://www.*-*-*.com/ ;)

Response.Redirect("postpage.aspx")

End Sub

End Class



Sun, 07 Aug 2005 06:32:45 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Post data from one page to another (BOA page) vb.net

2. How to post data from one asp.net page to another

3. web page that post from a single page

4. Page refresh re-post the data.

5. Debug VB.NET DLL(Class Library) from ASP.NET page

6. Passing Form Fields to VB.NET Custom Business Object in an ASP.NET Code Behind Page

7. boxes in detail section at end of page although data forces new page

8. Page size for the background= Page size of the first page of the drawing

9. Page Footer on Page 1 Refers to Page 2

10. Page n of Total pages (or Max Pages function)

11. Page numbering and fit to page in Excel from VB

12. In a VB designer .dsr report can I hide the page header on page 1

 

 
Powered by phpBB® Forum Software