Decode QueryString and redirect to new form

Discussion in 'ASP .Net' started by Nirmal Singh, Oct 5, 2006.

  1. Nirmal Singh

    Nirmal Singh Guest

    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
     
    Nirmal Singh, Oct 5, 2006
    #1
    1. Advertising

  2. 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
     
    Chris Fulstow, Oct 5, 2006
    #2
    1. Advertising

  3. 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
    >
     
    David R. Longnecker, Oct 5, 2006
    #3
  4. Nirmal Singh

    Nirmal Singh Guest

    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





    "David R. Longnecker" <> wrote in message
    news:...

    > 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
    >>

    >
    >
     
    Nirmal Singh, Oct 5, 2006
    #4
  5. 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
    >
    > "David R. Longnecker" <> wrote in message
    > news:...
    >
    >> 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
    >>>
     
    David R. Longnecker, Oct 6, 2006
    #5
  6. Nirmal Singh

    Nirmal Singh Guest

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


    "David R. Longnecker" <> wrote in message
    news:...
    > 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
    >>
    >> "David R. Longnecker" <> wrote in message
    >> news:...
    >>
    >>> 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
    >>>>

    >
    >
     
    Nirmal Singh, Oct 10, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. EDOnLine
    Replies:
    3
    Views:
    459
    intrader
    Mar 28, 2006
  2. Mehdi
    Replies:
    6
    Views:
    36,119
    sloan
    Apr 6, 2006
  3. Sal
    Replies:
    1
    Views:
    508
  4. Adeel Ahmad
    Replies:
    1
    Views:
    516
    Anthony Jones
    Mar 7, 2006
  5. Larry
    Replies:
    3
    Views:
    95
    Tad McClellan
    Sep 25, 2004
Loading...

Share This Page