Control Not remembering property on postback

Discussion in 'ASP .Net Building Controls' started by Teemu Keiski, Jul 13, 2005.

  1. Teemu Keiski

    Teemu Keiski Guest

    Hi,

    where in the lifecycle / events you reading/writing the value? Init, Load,
    postback event, PreRender...?
     
    Teemu Keiski, Jul 13, 2005
    #1
    1. Advertisements

  2. I am having problems getting my customer control to remember properties
    accross postback. I have tried setting it to a session. What is the
    recommended way of doing this.

    I have tried this
    'set it to session
    _location = Value.ToString()
    System.Web.HttpContext.Current.Session("XmlPath") = _location

    'on the postback where I have the problem if the location is empty read in
    the session

    if _location = "" then
    _location = System.Web.HttpContext.Current.Session("XmlPath")
    end if
     
    Chris Kennedy, Jul 13, 2005
    #2
    1. Advertisements

  3. Teemu Keiski

    Teemu Keiski Guest

    If I understand correctly what you mean (just in member declarations), then
    yes, it could be the reason. Try setting it in some event like Load (it just
    should be set before accessed).

    Are you still reading it normally in some event?.
     
    Teemu Keiski, Jul 13, 2005
    #3
  4. I am just setting the property in the public declarations like with any
    object. This is in any event. Is this where I am going wrong?
     
    Chris Kennedy, Jul 14, 2005
    #4
  5. The property is set in the Load event of the parent page. It's just on
    postback the control doesn't remember the property?

    The control has some control and a button control. I have added an event to
    the button click. When I try to access the property in the onCLick event it
    can't find the property.
     
    Chris Kennedy, Jul 15, 2005
    #5
  6. Teemu Keiski

    Teemu Keiski Guest

    Post the entire code which is relevant to this scenario.
     
    Teemu Keiski, Jul 18, 2005
    #6
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.