I've traditionally used classes just for functions and subs. I was playing around with using a class with lots of properties. But as the page posts back the object has to be reinstaniated and looses the values for the instance because it always creates the object all over again. Putting the instantiation in the Ifnotispostback doesn't help cause the object gets redimmed even before the load each time....here's the code:
Only when I assign values within the click event of the last button does the text show the values...
Dim mPatient As clsPatient
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
mPatient = New clsPatient
End If
End Sub
Public Sub btnAddClass_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddClass.Click
'Assign values to the instance
mPatient.FirstName = txtFirstName.Text
mPatient.Phone = txtPhone.Text
End Sub
Private Sub btnViewClass_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnViewClass.Click
lblOutput.Text = "The Patient Name is " & mPatient.FirstName & " the Phone# is " & mPatient.Phone & "."
End Sub
How's this done in ASP.NET using classes with properties....must the class be instantiated and recieve values all within the same sub each time??
TIA
Harry