Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Decode QueryString and redirect to new form

Reply
Thread Tools

Decode QueryString and redirect to new form

 
 
Nirmal Singh
Guest
Posts: n/a
 
      10-05-2006
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


 
Reply With Quote
 
 
 
 
Chris Fulstow
Guest
Posts: n/a
 
      10-05-2006
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


 
Reply With Quote
 
 
 
 
David R. Longnecker
Guest
Posts: n/a
 
      10-05-2006
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
>



 
Reply With Quote
 
Nirmal Singh
Guest
Posts: n/a
 
      10-05-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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
>>

>
>



 
Reply With Quote
 
David R. Longnecker
Guest
Posts: n/a
 
      10-06-2006
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) 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
>>>



 
Reply With Quote
 
Nirmal Singh
Guest
Posts: n/a
 
      10-10-2006
Thanks for that David, I'll try it when I get back from leave.


"David R. Longnecker" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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).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" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed) 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
>>>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get value of QueryString inside QueryString Mehdi ASP .Net 6 04-06-2006 03:41 PM
Newbe: Redirect and QueryString HELP PLZ EDOnLine ASP .Net 3 03-28-2006 01:37 AM
Passing QueryString URL as a paremeter in QueryString Adeel Ahmad ASP General 1 03-07-2006 02:05 PM
Converting a Response.Redirect's URL from querystring-based to other Keith Patrick ASP .Net 6 07-22-2004 02:16 PM
Basic Q - Response.Redirect, all redirect to first Response.Redirect statement Sal ASP .Net Web Controls 1 05-15-2004 03:46 PM



Advertisments