473,395 Members | 2,795 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,395 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 1130
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.