Inheritance + Postback issues

Discussion in 'ASP .Net' started by macduder83, Apr 14, 2005.

  1. macduder83

    macduder83 Guest

    All,

    I 2 classes, parent and child class. I instantiate the child class by
    doing the following:

    I have a property that looks like this

    Private Property propChild() As ChildClass
    Get
    Return CType(Session(ChildClass.NAMES.C_NAME), ChildClass)
    End Get
    Set(ByVal Value As ChildClass)
    Session(ChildClass.NAMES.C_NAME) = Value
    End Set
    End Property

    I then set the property by doing this

    Me.propChild = new ChildClass()

    When I call the constructor( new ) for the ChildClass it fires off the
    New for the parent class. This is fine and desired behavior. Problem is
    that ASP.NET seems to add the child class to the session and all of its
    members(strings,ints and so on) the problem is that it loses all the
    parent information. The parent has a few properties I need but they are
    lost after a postback. I have tried useing Application and Session. I
    do not want to go to viewstate as that may be the wrong place to store
    complex data types. If anyone has a solution that would be greatly
    appreciated.

    Thanks !
     
    macduder83, Apr 14, 2005
    #1
    1. Advertising

  2. macduder83

    Scott Allen Guest

    Hi macduder:

    Do you have some more code to show how you pull the object out of
    session?

    --s

    On 13 Apr 2005 20:33:10 -0700, "macduder83"
    <> wrote:

    >All,
    >
    >I 2 classes, parent and child class. I instantiate the child class by
    >doing the following:
    >
    >I have a property that looks like this
    >
    > Private Property propChild() As ChildClass
    > Get
    > Return CType(Session(ChildClass.NAMES.C_NAME), ChildClass)
    > End Get
    > Set(ByVal Value As ChildClass)
    > Session(ChildClass.NAMES.C_NAME) = Value
    > End Set
    > End Property
    >
    >I then set the property by doing this
    >
    > Me.propChild = new ChildClass()
    >
    >When I call the constructor( new ) for the ChildClass it fires off the
    >New for the parent class. This is fine and desired behavior. Problem is
    >that ASP.NET seems to add the child class to the session and all of its
    >members(strings,ints and so on) the problem is that it loses all the
    >parent information. The parent has a few properties I need but they are
    >lost after a postback. I have tried useing Application and Session. I
    >do not want to go to viewstate as that may be the wrong place to store
    >complex data types. If anyone has a solution that would be greatly
    >appreciated.
    >
    >Thanks !


    --
    Scott
    http://www.OdeToCode.com/blogs/scott/
     
    Scott Allen, Apr 15, 2005
    #2
    1. Advertising

  3. macduder83

    macduder83 Guest

    I have figured it out. I was calling a Load method incorrectly, which
    was nuking a few of the properties.
     
    macduder83, Apr 15, 2005
    #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. Matthew

    Inheritance Issues

    Matthew, Nov 20, 2003, in forum: C++
    Replies:
    5
    Views:
    312
    jeffc
    Nov 20, 2003
  2. scorp007
    Replies:
    9
    Views:
    344
    Bo Yang
    Dec 9, 2006
  3. Alexander Adam

    Issues with multiple inheritance

    Alexander Adam, Mar 24, 2007, in forum: C++
    Replies:
    2
    Views:
    358
    Adrian Hawryluk
    Mar 24, 2007
  4. Mahesh
    Replies:
    2
    Views:
    451
  5. M Nauman Ur Rehman

    Login Control inheritance issues

    M Nauman Ur Rehman, Jan 24, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    121
    M Nauman Ur Rehman
    Jan 24, 2006
Loading...

Share This Page