Property value of a Class not retained

mpdillon

Member
Joined
Feb 17, 2005
Messages
20
Location
Glen Mills, PA
Programming Experience
Beginner
I am trying to understand Classes. I have a Web App with two forms and one Class. The class contains a property, "Name". In each form I "DIM clsVariable as new Class1". As I am exiting the first form I set the "Name" Property of the Class to Bob. When the second page loads I check the value of the "Name" property of Class1 and it is Nothing. Why is the Property of the class not retaining the value? How do I get the property to retain its value between forms.
Thanks
 

Paszt

Staff member
Joined
Jun 3, 2004
Messages
1,500
Location
Raleigh, NC - USA
Programming Experience
Beginner
When you DIM clsVariable (declare the variable), you do so at the class level. That makes the vaiable a class variable (as the form is a class). When you exit the form, all information contained in that class is also lost. If you want to retain the value, with Web Forms look into session variables (for saving the value during the same session) or possibly cookies. You can also send variable to other pages using POSTs.
 
Top Bottom