473,320 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Is there any way to do a post to another page in the code behind?

Sometimes you want to transfer to another page and pass some values along
not using the query string nor the session.
Is there some way to do this?

cheers,
mortb
Nov 18 '05 #1
3 1306
You can do a post using the WebClient class. Here's some sample code. The
values to post go in the NameValueCollection

Sub DoPost()
Dim uriString As String = _
"http://localhost/p4320work/mySpecialPage.aspx"
Dim strGoName As String
strGoName = TextBox1.Text
' Create a new WebClient instance.
Dim myWebClient As New System.Net.WebClient
Dim myNameValueCollection As New _
System.Collections.Specialized.NameValueCollection
myNameValueCollection.Add("go1", strGoName)
myNameValueCollection.Add("Button1", "")
Dim responseArray As Byte() = myWebClient.UploadValues _
(uriString, "POST", myNameValueCollection)

Label1.Text = "Response received was :" & _
System.Text.Encoding.ASCII.GetString(responseArray )
End Sub

Ken
Microsoft MVP [ASP.NET]
Toronto

"mortb" <mortb1<noospam<@hotmail.com> wrote in message
news:%2******************@TK2MSFTNGP15.phx.gbl...
Sometimes you want to transfer to another page and pass some values along
not using the query string nor the session.
Is there some way to do this?

cheers,
mortb


Nov 18 '05 #2
Is it not possible to go directly to the page like response.redirect but
using a post instead?
As if the form would post to another page?

/mortb

"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
You can do a post using the WebClient class. Here's some sample code. The
values to post go in the NameValueCollection

Sub DoPost()
Dim uriString As String = _
"http://localhost/p4320work/mySpecialPage.aspx"
Dim strGoName As String
strGoName = TextBox1.Text
' Create a new WebClient instance.
Dim myWebClient As New System.Net.WebClient
Dim myNameValueCollection As New _
System.Collections.Specialized.NameValueCollection
myNameValueCollection.Add("go1", strGoName)
myNameValueCollection.Add("Button1", "")
Dim responseArray As Byte() = myWebClient.UploadValues _
(uriString, "POST", myNameValueCollection)

Label1.Text = "Response received was :" & _
System.Text.Encoding.ASCII.GetString(responseArray )
End Sub

Ken
Microsoft MVP [ASP.NET]
Toronto

"mortb" <mortb1<noospam<@hotmail.com> wrote in message
news:%2******************@TK2MSFTNGP15.phx.gbl...
Sometimes you want to transfer to another page and pass some values along
not using the query string nor the session.
Is there some way to do this?

cheers,
mortb

Nov 18 '05 #3
You can :
- alter the action attribute of the form tag using JavaScript
- on google you'll find form controls adding the explicit handling of the
form attribute
- the next release also adds support for this

You could use also Server.Transfer (if you don't need the browser to see the
final URL)

Patrice

--

"mortb" <mortb1<noospam<@hotmail.com> a écrit dans le message de
news:uH**************@tk2msftngp13.phx.gbl...
Is it not possible to go directly to the page like response.redirect but
using a post instead?
As if the form would post to another page?

/mortb

"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
You can do a post using the WebClient class. Here's some sample code. The values to post go in the NameValueCollection

Sub DoPost()
Dim uriString As String = _
"http://localhost/p4320work/mySpecialPage.aspx"
Dim strGoName As String
strGoName = TextBox1.Text
' Create a new WebClient instance.
Dim myWebClient As New System.Net.WebClient
Dim myNameValueCollection As New _
System.Collections.Specialized.NameValueCollection
myNameValueCollection.Add("go1", strGoName)
myNameValueCollection.Add("Button1", "")
Dim responseArray As Byte() = myWebClient.UploadValues _
(uriString, "POST", myNameValueCollection)

Label1.Text = "Response received was :" & _
System.Text.Encoding.ASCII.GetString(responseArray )
End Sub

Ken
Microsoft MVP [ASP.NET]
Toronto

"mortb" <mortb1<noospam<@hotmail.com> wrote in message
news:%2******************@TK2MSFTNGP15.phx.gbl...
Sometimes you want to transfer to another page and pass some values along not using the query string nor the session.
Is there some way to do this?

cheers,
mortb


Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Eagle Rock | last post by:
Hi all, This is probably a simple question, but I'm just getting started in ASP.NET, and I can't find the answer. I have a simple form with a "Submit" button. When the user clicks on the...
6
by: Tom Rowton | last post by:
This one has me a bit confused and I'm not finding what I need in the MSDN or by searching these forums, so here goes... I have a rather large, complex code-in-page WebForm (don't ask) and a...
6
by: someone | last post by:
I am in a situation where I need to package some information from Page1, submit it via POST to another server which will process the information and then send the user to another page on my server...
5
by: Vishal | last post by:
Hello, I already asked this question in the ASP.NET forums, but no help came. So I am hoping that somebody can help me out. This is really very URGENT me. For my e-commerce application, I...
12
by: Britney | last post by:
Hi guys, in my default.aspx file, I have following code. when I go to browser, I enter values in both textboxs, then I hit submit Button, however, it didn't go to page2.aspx. instead, it was...
0
by: WIWA | last post by:
Hi, I want to login to a password protected website and fetch the content of the page behind. I have based my code on http://weblogs.asp.net/jdennany/archive/2005/04/23/403971.aspx. When I use...
0
by: joehaxor | last post by:
Hi! Thanks if anyone can answer this probably easy question. ASP.NET C# I have a .aspx page with a form that used POST method to send information (action="searchresults.aspx") However...
4
by: CSINVA | last post by:
Trying to figure out how to do a cross post page within the code behind file. I need to do some calculations before I send a string value to another pages. Here is an example of the concept I...
1
by: John Straumann | last post by:
Hello all: I am trying to call an ASPX page from another ASPX page code-behind file by using the HTTP Request object. By loading the page and typing: javascript:alert(resultRender.outerHTML) ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.