By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,708 Members | 2,080 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,708 IT Pros & Developers. It's quick & easy.

Decode QueryString and redirect to new form

P: n/a
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
Oct 5 '06 #1
Share this Question
Share on Google+
5 Replies


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

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

Nirmal Singh wrote:
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
Oct 5 '06 #2

P: n/a
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

Oct 5 '06 #3

P: n/a
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).DefaultVal ue =
mySession("DummyValue").ToString

End Sub

End Class

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

Where should I put the declaration?

Nirmal

"David R. Longnecker" <dl*********@community.nospamwrote in message
news:46************************@msnews.microsoft.c om...
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


Oct 5 '06 #4

P: n/a
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).DefaultVal ue = 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).DefaultVal ue =
mySession("DummyValue").ToString

End Sub

End Class

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

Where should I put the declaration?

Nirmal

"David R. Longnecker" <dl*********@community.nospamwrote in message
news:46************************@msnews.microsoft.c om...
>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

Oct 6 '06 #5

P: n/a
Thanks for that David, I'll try it when I get back from leave.
"David R. Longnecker" <dl*********@community.nospamwrote in message
news:46************************@msnews.microsoft.c om...
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).DefaultVal ue =
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).DefaultVa lue =
mySession("DummyValue").ToString

End Sub

End Class

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

Where should I put the declaration?

Nirmal

"David R. Longnecker" <dl*********@community.nospamwrote in message
news:46************************@msnews.microsoft. com...
>>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


Oct 10 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.