How to DIM an object so that scope is visible in all forms

  • Thread starter Thread starter refer_to_website
  • Start date Start date
R

refer_to_website

In my VB.NET web application, I created a class module called "Person"
with various properties and methods. The Login method reads the
person's data (name, address, etc.) from a database. The web screens
access the database via getters and setters in the Person class
module.

The code-behind of my home page's login button has
dim oCurrentPerson As New Person
oCurrentPerson.Login (me.txtUserName.text, me.txtPassword.text)
Response.Redirect ("detail.aspx")

On the second form (detail.aspx), oCurrentPerson is not accessible
(it's out of scope). Where / how can I declare oCurrentPerson so that
I can access it on all the forms of my web site?

I've tried Public and Static. I've tried dimensioning it in
global.asax or at the top of the home page without success.
 
I tried that, but it appears that session variables can only store
intrinsic variables (i.e. strings, integers, etc.). I would need it
to store an OBJECT.

Attempting to "dim oCurrentPerson As New Person" in the global.asax,
and then using it in the code-behind of a web form does not work (out
of scope). This seems like it should work to me. If you can get it
to work, PLEASE show me how!
 
Back
Top