Problem retrieving context values

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • antonyliu2002@yahoo.com

    Problem retrieving context values

    This message was originally a follow-up in a thread, but it went
    ignored and I do want some help so I am initiating it as a new topic.

    After Patrick and Karl showed me some examples, I was trying to retain
    user data across multiple pages using the Context facility.

    On page1.aspx, I have

    Page1 | Page2 |

    First Name:
    Last Name:

    Where Page1 and Page2 are LinkButton objects that point to the
    respective pages. These two buttons also appear on page2.aspx.

    On page2.aspx, I do get the info transferred from page1.aspx. But when
    I hit the LinkButton Page1 to go back, the information is lost. And on
    page1.aspx, I do have the following Sub:

    Sub Page_Load(sende r As Object, e As EventArgs)
    If Not Page.IsPostBack Then
    txtFirst.Text = Context.Items(" first")
    txtLast.Text = Context.Items(" last")
    End If
    End Sub

    Presumably, this sub should be able to retrieve the values from the
    context and put them back to their respective textboxes.

    I tried CTyping like so,

    txtFirst.Text = CType(Context.I tems("first"), String)
    txtLast.Text = CType(Context.I tems("Last"), String)

    It did not help.

    Well, I know that the values will still be there if I hit the back
    button of the browser. But that is not what I want.

    Please let me know where I went wrong. Thanks a lot.

  • srini

    #2
    RE: Problem retrieving context values

    Ignore this if i got you wrong..
    but Context object can hold data only for a single request.. So if you are
    going to page 2 and coming back to page1 i guess you are loosing the data
    because you are making two requests..
    --
    HTH
    srini



    "antonyliu2002@ yahoo.com" wrote:
    [color=blue]
    > This message was originally a follow-up in a thread, but it went
    > ignored and I do want some help so I am initiating it as a new topic.
    >
    > After Patrick and Karl showed me some examples, I was trying to retain
    > user data across multiple pages using the Context facility.
    >
    > On page1.aspx, I have
    >
    > Page1 | Page2 |
    >
    > First Name:
    > Last Name:
    >
    > Where Page1 and Page2 are LinkButton objects that point to the
    > respective pages. These two buttons also appear on page2.aspx.
    >
    > On page2.aspx, I do get the info transferred from page1.aspx. But when
    > I hit the LinkButton Page1 to go back, the information is lost. And on
    > page1.aspx, I do have the following Sub:
    >
    > Sub Page_Load(sende r As Object, e As EventArgs)
    > If Not Page.IsPostBack Then
    > txtFirst.Text = Context.Items(" first")
    > txtLast.Text = Context.Items(" last")
    > End If
    > End Sub
    >
    > Presumably, this sub should be able to retrieve the values from the
    > context and put them back to their respective textboxes.
    >
    > I tried CTyping like so,
    >
    > txtFirst.Text = CType(Context.I tems("first"), String)
    > txtLast.Text = CType(Context.I tems("Last"), String)
    >
    > It did not help.
    >
    > Well, I know that the values will still be there if I hit the back
    > button of the browser. But that is not what I want.
    >
    > Please let me know where I went wrong. Thanks a lot.
    >
    >[/color]

    Comment

    Working...