473,287 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Persisting Classes over page postbacks

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))
May 16 '06 #1
3 1127
Jon
Hello.

Could you hold it on the session?

"steven scaife" wrote:
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))

May 16 '06 #2
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

"steven scaife" <st**********@discussions.microsoft.com> wrote in message
news:89**********************************@microsof t.com...
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))

May 16 '06 #3
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

"Rick Strahl (MVP)" wrote:
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

"steven scaife" <st**********@discussions.microsoft.com> wrote in message
news:89**********************************@microsof t.com...
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))


May 17 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Citoyen du Monde | last post by:
Trying to get some ideas on a simple javascript project (to teach myself the language). I want to develop a client-side vocabulary practice application that would allow users to enter their own...
1
by: David Anderson | last post by:
I'm having trouble persisting viewstate information for webcontrols I've disabled via javascript. I have a group of textboxes that I enable/disable via a checkbox control that invokes a javascript...
0
by: Tomas Vera | last post by:
Here's another goofy thing. I need to persist the state of items added dynamically to a Panel control between round-trips to the server. I have a web form that contains a TreeView and a...
8
by: John Smith Jr. | last post by:
I am looking for some way to persist a table web control so when page_load event comes up, i can display the table as it was. I tried using ViewState with the rows collection but that didn't work...
2
by: headware | last post by:
I am new to 3-tiered design and am in the process of designing an application that will work with ASP.NET as well as Windows Forms (and possibly with a PDA of some sort down the road). My question...
3
by: Stu | last post by:
Hi, I am creating a control in a PlaceHolder like so: Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click Dim ctrl As...
5
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens...
0
by: Homer J. Simpson | last post by:
A few weeks ago I asked for suggestions on how to persist a tree's node state to cookies, without causing postbacks on each click in the tree. I had a single .aspx file, with a row of buttons on...
4
by: jhalavirendra | last post by:
Hi All, I am using ASP.NET 2.0 and C#. I am opening a Modal Dialog Box from .aspx page. This dialgo box contains a grid and user can add new recod to this grid from here. When this dialgo...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.