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 functionAdtmitedly this doesn't work yet because its not serialized, i'm also
working on how to do that as well
"Namshub" <Richard._NoSpam_ForME_Pullen@.Southend.nhs.uk> wrote in message
news:eqKZwy8KFHA.1176@.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
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" <Richard._NoSpam_ForME_Pullen@.Southend.nhs.uk> wrote in message
news:eqKZwy8KFHA.1176@.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
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" <Richard._NoSpam_ForME_Pullen@.Southend.nhs.uk> wrote in message
news:eqKZwy8KFHA.1176@.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
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/...terGetAtIt.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
>
>
0 comments:
Post a Comment