ASPX Post to another page

Discussion in 'ASP General' started by Mark, Oct 12, 2005.

  1. Mark

    Mark Guest

    I have created the following code to post data from a textbox to another page
    (post.aspx). I created the lblResponse to prove to myself that something was
    actually getting posted, and that works. However when you click the button
    it does not take you to the post.aspx page. It just refreshes the page! Any
    ideas whats up with this?

    Sub post_click(ByVal s As Object, ByVal e As EventArgs)
    Dim objRequest As HttpWebRequest
    Dim strRequest As String
    Dim arrRequest As Byte()
    Dim objUTF8Encoding As UTF8Encoding
    Dim strmRequest As Stream
    Dim objResponse As HttpWebResponse
    Dim srResponse As StreamReader

    ' Initialize request object
    objRequest =
    CType(WebRequest.Create("http://localhost/rsfront/post.aspx"), HttpWebRequest)
    objRequest.Method = "POST"
    objRequest.ContentType = "application/x-www-form-urlencoded"
    'objRequest.AllowAutoRedirect = True

    ' Create request body
    strRequest = "Dept=" & Server.UrlEncode(txtDept1.Text)
    objUTF8Encoding = New UTF8Encoding
    arrRequest = objUTF8Encoding.GetBytes(strRequest)

    ' Add body to request
    objRequest.ContentLength = arrRequest.Length
    strmRequest = objRequest.GetRequestStream()
    strmRequest.Write(arrRequest, 0, arrRequest.Length)
    strmRequest.Close()

    ' Get response
    objResponse = objRequest.GetResponse()
    srResponse = New StreamReader(objResponse.GetResponseStream(),
    Encoding.ASCII)
    lblResponse.Text = srResponse.ReadToEnd()
    srResponse.Close()
    End Sub
    ----
    Mark
    Mark, Oct 12, 2005
    #1
    1. Advertising

  2. Mark wrote:
    > I have created the following code to post data from a textbox to
    > another page (post.aspx).


    There was no way for you to know it, but this is a classic asp newsgroup.
    While you may be lucky enough to find a dotnet-knowledgeable person here who
    can answer your question, you can eliminate the luck factor by posting your
    question to a group where those dotnet-knowledgeable people hang out. I
    suggest microsoft.public.dotnet.framework.aspnet.

    Unfortunately, I'm still finding my way around .Net, and was unaware that
    this method could be used to redirect a request (I thought one had to do
    server.transfer or response.redirect). Hopefully someone at the aspnet group
    can help you.

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows [MVP], Oct 12, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sriram Mallajyosula

    How do I post data from aspx page to another aspx page.

    Sriram Mallajyosula, Nov 5, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    946
    Steve C. Orr [MVP, MCSD]
    Nov 5, 2003
  2. Srinivasa Raghavan Sethuraman

    Post Data ASP web page from ASPX Page

    Srinivasa Raghavan Sethuraman, Jul 20, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    594
    John Saunders
    Jul 20, 2004
  3. Ricardo Magalhaes
    Replies:
    0
    Views:
    803
    Ricardo Magalhaes
    Jun 3, 2005
  4. =?Utf-8?B?Uk1M?=
    Replies:
    1
    Views:
    533
    =?Utf-8?B?QW5keSBMdWtzaWM=?=
    Sep 16, 2005
  5. =?Utf-8?B?TU9VU1RBRkEgQVJBRkE=?=

    POST data from aspx page to asp page

    =?Utf-8?B?TU9VU1RBRkEgQVJBRkE=?=, Oct 4, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    1,480
    =?Utf-8?B?TU9VU1RBRkEgQVJBRkE=?=
    Oct 6, 2006
Loading...

Share This Page