Decode QueryString and redirect to new form

N

Nirmal Singh

I am a newbie trying to learn ASP.net 2.0.

I want to retrieve the QueryString and process it to produce some
parameters.

I then want to redirect the user to another page, passing these parameters,
but not as a querystring.

Any help would be gratefully received.

Nirmal Singh
 
C

Chris Fulstow

To retrieve querystring parameters:
string qsValue = Request.QueryString("paramName");

To Redirect:
Response.Redirect("yourpage.aspx?param=" +
HttpUtility.UrlEncode(value));
 
D

David R. Longnecker

Chris is right on it for the querystring. You asked to redirect to another
page and pass parameters, but not as a query string.

To do this, you could use session state. Building on Chris' code:

On first page:

String qsValue = Request.QueryString["paramName"];


<-- qsValue data manipulation here -->

Session["qsValue"] = qsValue;
Response.Redirect("yourpage.aspx");

On second page:

String sessionValue = Session["qsValue].ToString();

From here you can manipulate it however you wish on the second, or subsequent,
pages.
 
N

Nirmal Singh

Thanks for your help, David.



I am using the following code in page 1.



Partial Class _Default



Inherits System.Web.UI.Page



Public instance As Page

Public mySession As HttpSessionState



Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

Response.BufferOutput = True

instance = New Page

mySession = instance.Session

mySession("DummyValue") = "A500300300" 'I am using a dummy
value at the moment, this will be replaced from the QueryString

Response.Redirect("EmpList.aspx")

End Sub



End Class





In page 2 I have put in the following code:



Partial Class EmpList



Inherits System.Web.UI.Page



Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load

SqlDataSource1.SelectParameters.Item(1).DefaultValue =
mySession("DummyValue").ToString

End Sub



End Class



Here, it is complaining that mySession has not been declared.

Where should I put the declaration?



Nirmal





Chris is right on it for the querystring. You asked to redirect to
another page and pass parameters, but not as a query string.

To do this, you could use session state. Building on Chris' code:

On first page:

String qsValue = Request.QueryString["paramName"];


<-- qsValue data manipulation here -->

Session["qsValue"] = qsValue;
Response.Redirect("yourpage.aspx");

On second page:

String sessionValue = Session["qsValue].ToString();

From here you can manipulate it however you wish on the second, or
subsequent, pages.

--
David Longnecker
Web Developer
http://blog.tiredstudent.com
I am a newbie trying to learn ASP.net 2.0.

I want to retrieve the QueryString and process it to produce some
parameters.

I then want to redirect the user to another page, passing these
parameters, but not as a querystring.

Any help would be gratefully received.

Nirmal Singh
 
D

David R. Longnecker

On your second page, recreate your instance objects:

Partial Class EmpList
Inherits System.Web.UI.Page
Public instance As Page
Public mySession As HttpSessionState

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
instance = New Page
mySession = instance.Session

SqlDataSource1.SelectParameters.Item(1).DefaultValue = mySession("DummyValue").ToString

End Sub
End Class

-dl

--
David Longnecker
Web Developer
http://blog.tiredstudent.com
Thanks for your help, David.

I am using the following code in page 1.

Partial Class _Default

Inherits System.Web.UI.Page

Public instance As Page

Public mySession As HttpSessionState

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

Response.BufferOutput = True

instance = New Page

mySession = instance.Session

mySession("DummyValue") = "A500300300" 'I am using a
dummy value at the moment, this will be replaced from the QueryString

Response.Redirect("EmpList.aspx")

End Sub

End Class

In page 2 I have put in the following code:

Partial Class EmpList

Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

SqlDataSource1.SelectParameters.Item(1).DefaultValue =
mySession("DummyValue").ToString

End Sub

End Class

Here, it is complaining that mySession has not been declared.

Where should I put the declaration?

Nirmal

Chris is right on it for the querystring. You asked to redirect to
another page and pass parameters, but not as a query string.

To do this, you could use session state. Building on Chris' code:

On first page:

String qsValue = Request.QueryString["paramName"];

<-- qsValue data manipulation here -->

Session["qsValue"] = qsValue;
Response.Redirect("yourpage.aspx");
On second page:

String sessionValue = Session["qsValue].ToString();

From here you can manipulate it however you wish on the second, or
subsequent, pages.

--
David Longnecker
Web Developer
http://blog.tiredstudent.com
I am a newbie trying to learn ASP.net 2.0.

I want to retrieve the QueryString and process it to produce some
parameters.

I then want to redirect the user to another page, passing these
parameters, but not as a querystring.

Any help would be gratefully received.

Nirmal Singh
 
N

Nirmal Singh

Thanks for that David, I'll try it when I get back from leave.


David R. Longnecker said:
On your second page, recreate your instance objects:

Partial Class EmpList
Inherits System.Web.UI.Page
Public instance As Page
Public mySession As HttpSessionState

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
instance = New Page
mySession = instance.Session

SqlDataSource1.SelectParameters.Item(1).DefaultValue =
mySession("DummyValue").ToString

End Sub
End Class

-dl

--
David Longnecker
Web Developer
http://blog.tiredstudent.com
Thanks for your help, David.

I am using the following code in page 1.

Partial Class _Default

Inherits System.Web.UI.Page

Public instance As Page

Public mySession As HttpSessionState

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

Response.BufferOutput = True

instance = New Page

mySession = instance.Session

mySession("DummyValue") = "A500300300" 'I am using a
dummy value at the moment, this will be replaced from the QueryString

Response.Redirect("EmpList.aspx")

End Sub

End Class

In page 2 I have put in the following code:

Partial Class EmpList

Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

SqlDataSource1.SelectParameters.Item(1).DefaultValue =
mySession("DummyValue").ToString

End Sub

End Class

Here, it is complaining that mySession has not been declared.

Where should I put the declaration?

Nirmal

Chris is right on it for the querystring. You asked to redirect to
another page and pass parameters, but not as a query string.

To do this, you could use session state. Building on Chris' code:

On first page:

String qsValue = Request.QueryString["paramName"];

<-- qsValue data manipulation here -->

Session["qsValue"] = qsValue;
Response.Redirect("yourpage.aspx");
On second page:

String sessionValue = Session["qsValue].ToString();

From here you can manipulate it however you wish on the second, or
subsequent, pages.

--
David Longnecker
Web Developer
http://blog.tiredstudent.com
I am a newbie trying to learn ASP.net 2.0.

I want to retrieve the QueryString and process it to produce some
parameters.

I then want to redirect the user to another page, passing these
parameters, but not as a querystring.

Any help would be gratefully received.

Nirmal Singh
 

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

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top