Persisting Classes over page postbacks

G

Guest

I have written a class that stores some values in a class. I want to
instantiate this on page load or whichever event is appropriate. However when
the page postbacks i want to use the first instantiation of the class until i
submit the page through the submit button. However i cant get it to pass the
class through subsequent requests.

Can anyone help me out with either samples or websites that can help me out

thanks in advance

my code is below

<Serializable()> _
Public Class Ticket
Inherits DictionaryBase

Sub add(ByVal key As String, ByVal av As String)
Me.Dictionary.Add(key, av)
End Sub

Sub remove(ByVal key As String)
Me.Dictionary.Remove(key)
End Sub

Default Overloads Property item(ByVal key As String) As TicketValues
Get
Return CType(Me.Dictionary.Item(key), TicketValues)
End Get
Set(ByVal Value As TicketValues)
Me.Dictionary.Item(key) = Value
End Set
End Property

Private m_ValuesSet As Boolean

Public Property ValuesSet() As Boolean
Get
Return m_ValuesSet
End Get
Set(ByVal Value As Boolean)
ValuesSet = Value
End Set
End Property
End Class

Public Class TicketValues
Private m_TicketField As String

Public Property TicketField() As String
Get
Return m_TicketField
End Get
Set(ByVal Value As String)
m_TicketField = Value
End Set
End Property
End Class

then in my web page i have this code to add to the class

TicketStuff.add("RadList", CType(dr(3), String))
 
R

Rick Strahl \(MVP\)

Steven,

You can easily persist any serializable object in a Session object which is
user specific, but that doesn't mean that that's necessary a good idea. In
your case it looks like you only have a couple of values to persist and if
soI would write these individual values intoViewState or the Session.

+++ Rick ---

--

Rick Strahl
West Wind Technologies
www.west-wind.com
www.west-wind.com/weblog
 
G

Guest

yeah i keep thinking too complex when the simpler things will work easier, I
coded it to use an array instead so i can still use the loops in th eroutine
i have written
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top