Passing values between two pages

Discussion in 'ASP .Net' started by John, Jul 10, 2006.

  1. John

    John Guest

    Hi

    In my source page I am using;

    Context.Items("Msg") = Msg
    Response.Redirect("Destination_Page.aspx")

    In my destination page in Page_Load event I am using;

    lblMsg.Text = CType(Context.Items("Msg"), String)

    But the value does not get to the destination page. Is there a more
    reliable way to pass a string between pages?

    Thanks

    Regards
    John, Jul 10, 2006
    #1
    1. Advertising

  2. John

    sloan Guest

    Try a Server.Transfer("WebForm2.aspx");
    instead of Redirect.


    Note this technique does not work if you use Response.Redirect. A Redirect
    results in another round trip to the client and a new HTTP request - thus a
    new Context object without our ArrayList. To span requests, you'll need to
    use the Session object or another state container. Also, there are other
    techniques you can use to pass state between two forms when using
    Server.Transfer, these other techniques can be found in the resources
    section of the article.
    http://www.odetocode.com/Articles/111.aspx

    "John" <> wrote in message
    news:...
    > Hi
    >
    > In my source page I am using;
    >
    > Context.Items("Msg") = Msg
    > Response.Redirect("Destination_Page.aspx")
    >
    > In my destination page in Page_Load event I am using;
    >
    > lblMsg.Text = CType(Context.Items("Msg"), String)
    >
    > But the value does not get to the destination page. Is there a more
    > reliable way to pass a string between pages?
    >
    > Thanks
    >
    > Regards
    >
    >
    sloan, Jul 10, 2006
    #2
    1. Advertising

  3. If you use Server.Transfer then on the next page you can reference the
    PreviousPage object and use the FindControl method to gain reference to
    whatever control you want on the previous page (the one that did the
    transfer).

    --
    -Demetri


    "sloan" wrote:

    > Try a Server.Transfer("WebForm2.aspx");
    > instead of Redirect.
    >
    >
    > Note this technique does not work if you use Response.Redirect. A Redirect
    > results in another round trip to the client and a new HTTP request - thus a
    > new Context object without our ArrayList. To span requests, you'll need to
    > use the Session object or another state container. Also, there are other
    > techniques you can use to pass state between two forms when using
    > Server.Transfer, these other techniques can be found in the resources
    > section of the article.
    > http://www.odetocode.com/Articles/111.aspx
    >
    > "John" <> wrote in message
    > news:...
    > > Hi
    > >
    > > In my source page I am using;
    > >
    > > Context.Items("Msg") = Msg
    > > Response.Redirect("Destination_Page.aspx")
    > >
    > > In my destination page in Page_Load event I am using;
    > >
    > > lblMsg.Text = CType(Context.Items("Msg"), String)
    > >
    > > But the value does not get to the destination page. Is there a more
    > > reliable way to pass a string between pages?
    > >
    > > Thanks
    > >
    > > Regards
    > >
    > >

    >
    >
    >
    =?Utf-8?B?RGVtZXRyaQ==?=, Jul 10, 2006
    #3
    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. cgia
    Replies:
    5
    Views:
    756
    Steve C. Orr, MCSD
    Jul 26, 2003
  2. Matt M
    Replies:
    1
    Views:
    1,069
    Matt M
    Aug 28, 2003
  3. Greg Decos
    Replies:
    2
    Views:
    401
    Greg Decos
    Apr 15, 2004
  4. VS_NET_DEV
    Replies:
    2
    Views:
    3,790
    jenny
    May 25, 2004
  5. John

    Passing values between pages

    John, Oct 8, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    439
    Xavier Pacheco
    Oct 8, 2004
Loading...

Share This Page