Passing multiple values using Response.Redirect

A

Anne

hie there, i want to be able to pass multiple parameters
to another page. currently, i am able to do so, but
somehow i feel it is not the correct way to do it. below
is part of what i have so far.

'first page
Private Sub btnOK_ServerClick(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnOK.Click
Response.Redirect("InputValues.aspx?Requestor=" &
txtRequestor.Text & " Lower= " & txtLower.Text)
End Sub

'second page
Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim strRequestor As String
strRequestor = Request.QueryString("Requestor")
Response.Write("Requestor = " & strRequestor)
End Sub

the output i will get is :
Requestor = * Lower = 10

My question is, how can i pass the 2nd parameter(in the
txtLower.Text) to the next page without passing the
keyword "Lower" and still obtain the same output?

i want my second page to look like this:

Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim strRequestor As String
Dim strLower As String
strRequestor = Request.QueryString("Requestor")
Response.Write("Requestor = " & strRequestor)
Response.Write("<br>")
strLower = Request.QueryString("Lower")
Response.Write(strLower)
End Sub

Please help, and thanx in advance.
 
N

Natty Gur

Hi,

You can use Server.Transfer("InputValues.aspx",true) to call the
InputValues.aspx page with the Form and QueryString data.

You can also take advantage of Context while using
Server.Transfer("InputValues.aspx") and send any data that you want via
Context.Items

Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
 
A

Anne

hie natty. thanx 4 your reply. i've tried using your
method, but i still do not get the output i wanted, that
is how do i pass multiple parameters to the next page.
Thanx!
 
N

Natty Gur

Hi,
The calling page :
Context.Items.Add("DataA","yourData");
Context.Items.Add("ObjectData",System.DateTime.Now);

the target page :

string StringData = (string)Context["DataA"];
System.DateTime oDateTime = (System.DateTime)Context["ObjectData"]


Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
 
M

makthar

First method:

If you are using the request.querystring use "&" between
the values

Response.Redirect("InputValues.aspx?Requestor=" &
txtRequestor.Text & "&Lower= " & txtLower.Text)

InputValues.aspx page retrieve the values:

strRequestor = Request.QueryString("Requestor")
Response.Write("Requestor = " & strRequestor)

strLower = Request.QueryString("Lower")
Response.Write("Lower = " & strLower)

Second Method:

Use session Variables if you don't want to display these
values in the header

on page 1
session("Requestor")=txtRequestor.Text
Session("Lower")=txtlower.text
response.redirect("InputValues.aspx")

In the InputValues.aspx page
strRequestor=session("Requestor")
strLower=Session("Lower")
Session("Requestor")=nothing
Session("Lower")=nothing

Hope that helps.
 
D

David Waz...

Do you HAVE to use the 2nd page. Sometimes it's best to do the processing
in a single page...

Assuming you have to do it that way,
why not use Session to transfer the data. Just clean up after yourself on
the 2nd page by removing the values after you extract the values.
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top