473,320 Members | 1,909 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.

Decode QueryString and redirect to new form

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
5 7658
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Deepster | last post by:
Hi Guys Here is what I am doing ... Have a page default.asp which looks at the url and checks for querystring's. if there are none passed goes to a function. if there are particular querystrings...
4
by: Luklrc | last post by:
Hi, I'm having to create a querysting with javascript. My problem is that javscript turns the "&" characher into "&amp;" when it gets used as a querystring in the url EG: ...
0
by: Matt Howeson | last post by:
Some time ago I posted a request for help with a problem I was having sometime ago whereby a 404 error would result if any access to the Querystring had been made before the Context.Rewritepath is...
3
by: Jon | last post by:
Hi, I have hyperlink objects in a datagrid that redirect the user back to the current page with this syntax: <a href="mypage.aspx?id=foo"> When the page reloads, code in Page_Load then takes...
6
by: Keith Patrick | last post by:
I have to do some programmatic redirects (in several pages) based on URLs I am given from an external source. The URLs have querystrings at the end, but one in particular is about 240 chars long,...
5
by: Davids | last post by:
when using the page to POST (from a form) I want the page's querystring to be cleared, how do I do that?
2
by: Jim via DotNetMonster.com | last post by:
Hi, I'm passing a variable to another page through a querystring. I then want to use that variable to retrieve records from a database to poulate a dropdownlist. I can read the variable from the...
6
by: Joe | last post by:
Hello All: I have a webform (WebForm1.aspx) that retrieves a value from a database (_formSessionId) the first time that it is posted. After the user filles in the form, he/she clicks a Button...
2
by: JJ297 | last post by:
Could someone take a look at this code and tell me if this code is valid? Thanks! If Request.QueryString("quesid") <"" Then Response.Redirect("CDPadmineditpage.aspx?quesid = """) End If
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: 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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.