473,386 Members | 1,754 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,386 software developers and data experts.

persistance of Classes

I'm A client server developer by trade and i'm moving my skill set slowly
over to ASP.NET.

One question, I have a class, that i populate on a postback... I want to
keep this data persistant though other multiple postbacks.

What is the desired mechanism to use this.

I'm using the following code but not sure if this is the appropriate
solution to the problem

Private PatientDetails As Patient

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If ViewState("Patient") Is Nothing Then

PatientDetails = New Patient

viewstate.Add("Patient", PatientDetails)

Else

PatientDetails = New Patient

PatientDetails = viewstate("Patient")

End If

Private Function SearchPAS() As Boolean ' called by a button clik

PASmsg = PatientDetails.GetPASDetails(cSite, byCriteria, lbText.Text)
'which fills all the property fields

viewstate("Patient") = PatientDetails

end function

Nov 19 '05 #1
4 1099
Adtmitedly this doesn't work yet because its not serialized, i'm also
working on how to do that as well

"Namshub" <Ri**************************@Southend.nhs.uk> wrote in message
news:eq**************@TK2MSFTNGP12.phx.gbl...
I'm A client server developer by trade and i'm moving my skill set slowly
over to ASP.NET.

One question, I have a class, that i populate on a postback... I want to
keep this data persistant though other multiple postbacks.

What is the desired mechanism to use this.

I'm using the following code but not sure if this is the appropriate
solution to the problem

Private PatientDetails As Patient

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If ViewState("Patient") Is Nothing Then

PatientDetails = New Patient

viewstate.Add("Patient", PatientDetails)

Else

PatientDetails = New Patient

PatientDetails = viewstate("Patient")

End If

Private Function SearchPAS() As Boolean ' called by a button clik

PASmsg = PatientDetails.GetPASDetails(cSite, byCriteria, lbText.Text)
'which fills all the property fields

viewstate("Patient") = PatientDetails

end function


Nov 19 '05 #2
As long as your Patient class is serializable (which it apparently is), and
the extra HTML it adds to the document doesn't slow the response time down
too much, it's an excellent way to accomplish your goal. :)

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"Namshub" <Ri**************************@Southend.nhs.uk> wrote in message
news:eq**************@TK2MSFTNGP12.phx.gbl...
I'm A client server developer by trade and i'm moving my skill set slowly
over to ASP.NET.

One question, I have a class, that i populate on a postback... I want to
keep this data persistant though other multiple postbacks.

What is the desired mechanism to use this.

I'm using the following code but not sure if this is the appropriate
solution to the problem

Private PatientDetails As Patient

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If ViewState("Patient") Is Nothing Then

PatientDetails = New Patient

viewstate.Add("Patient", PatientDetails)

Else

PatientDetails = New Patient

PatientDetails = viewstate("Patient")

End If

Private Function SearchPAS() As Boolean ' called by a button clik

PASmsg = PatientDetails.GetPASDetails(cSite, byCriteria, lbText.Text)
'which fills all the property fields

viewstate("Patient") = PatientDetails

end function

Nov 19 '05 #3
Hi,
You have several methods of persisting data between postbacks:
1. Using the view state - The entire viewstate data is serialized to a
hidden input field in the output html and then deserialized at postback.
This is good if your object does not contain large amounts of data
(serialization to the output html = large html output = slow loading for the
user).
2. Using the session state. This way the data is saved on the server between
postbacks (there are 3 different session state configurations you should
read about in MSDN).

--
Eran Kampf
http://www.ekampf.com/blog
http://www.ekampf.com
"Namshub" <Ri**************************@Southend.nhs.uk> wrote in message
news:eq**************@TK2MSFTNGP12.phx.gbl...
I'm A client server developer by trade and i'm moving my skill set slowly
over to ASP.NET.

One question, I have a class, that i populate on a postback... I want to
keep this data persistant though other multiple postbacks.

What is the desired mechanism to use this.

I'm using the following code but not sure if this is the appropriate
solution to the problem

Private PatientDetails As Patient

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If ViewState("Patient") Is Nothing Then

PatientDetails = New Patient

viewstate.Add("Patient", PatientDetails)

Else

PatientDetails = New Patient

PatientDetails = viewstate("Patient")

End If

Private Function SearchPAS() As Boolean ' called by a button clik

PASmsg = PatientDetails.GetPASDetails(cSite, byCriteria, lbText.Text)
'which fills all the property fields

viewstate("Patient") = PatientDetails

end function

Nov 19 '05 #4
Here is an excellent article/blog on making the viewstate serialization the
most efficient for custom classes. In a nutshell, viewstate does a really
good job serializing a specific set of objects, for anything else, your
better off to create a custom type converter.

http://weblogs.asp.net/vga/archive/2...erGetAtIt.aspx

"Namshub" wrote:
I'm A client server developer by trade and i'm moving my skill set slowly
over to ASP.NET.

One question, I have a class, that i populate on a postback... I want to
keep this data persistant though other multiple postbacks.

What is the desired mechanism to use this.

I'm using the following code but not sure if this is the appropriate
solution to the problem

Private PatientDetails As Patient

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If ViewState("Patient") Is Nothing Then

PatientDetails = New Patient

viewstate.Add("Patient", PatientDetails)

Else

PatientDetails = New Patient

PatientDetails = viewstate("Patient")

End If

Private Function SearchPAS() As Boolean ' called by a button clik

PASmsg = PatientDetails.GetPASDetails(cSite, byCriteria, lbText.Text)
'which fills all the property fields

viewstate("Patient") = PatientDetails

end function

Nov 19 '05 #5

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

Similar topics

2
by: Leo | last post by:
Hi, I'm back to ASP for a short while and I was wondering how I could save the entire Application/Session-state to a file or database and how to read it back afterwards. I'd like to preserve...
0
by: Michael.McD | last post by:
Is there any consensus on the way to go when implementing object persistance to a dB? For example MHibernate v. DataObjects (x-tensive). Cheers, Michael McD
2
by: joye | last post by:
Hello, My question is how to use C# to call the existing libraries containing unmanaged C++ classes directly, but not use C# or managed C++ wrappers unmanaged C++ classes? Does anyone know how...
18
by: Edward Diener | last post by:
Is the packing alignment of __nogc classes stored as part of the assembly ? I think it must as the compiler, when referencing the assembly, could not know how the original data is packed otherwise....
1
by: CCORDON | last post by:
I have some classes that contain my objects...say..... Client...with all his properties, Methods & Events. I use this on my web pages like this. Dim MyClient as New Client(IdCorporation) ...
2
by: Kiran | last post by:
Hi, This is something weird I noticed recently in ASP.Net. I have created typed dataset and I have filled the data. when a postback happens, the data of the dataset is lost. Is there a...
3
by: CCORDON | last post by:
I have some classes that contain my objects...say..... Client...with all his properties, Methods & Events. I use this on my web pages like this. Dim MyClient as New Client(IdCorporation) ...
45
by: bigdadro | last post by:
I've created a new class using prototype.js. After I make the ajax.request all references to this.myClassMethodorVariable are lost. Does the ajax method blow out the object persistance? I'm fairly...
6
by: ivan.leben | last post by:
I want to write a Mesh class using half-edges. This class uses three other classes: Vertex, HalfEdge and Face. These classes should be linked properly in the process of building up the mesh by...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.