Variable & storing

Y

yop

Hello

I have an application, Login page, enter UserName &
Password.
Function in Users called GetUserDetails and checks the
details and if they are valid calls a function to fill
the following in the class component called

Public Class UserDetails
Public UserID As Integer
Public UserName As String
Public FullName As String
Public Email As String
End Class

So I would have thought now that what ever page I goto
that I could retreive the email or fullname from the
class above without having the call the GetUserDetails.

I use the following code.

'Load the User Name textbox
Dim userDetails As New
ASPNET.ASSETREGISTER.UserDetails()
msgfullname.Text = " Logged In: " &
userDetails.FullName

But it does not fill it, any ideas?
thanks in advance
 
C

Cowboy \(Gregory A. Beamer\)

Once you fill the object, where are you storing it? In session? Serialized
to disk? Not at all?

Since you are simply creating a group of properties/fields a struct might be
a better option, but you still have to store it:

Dim MyClass As UserDetails = new UserDetails()
'lines to fill class here
Session("MyClass") = MyClass

To use:
Dim MyClass as UserDetails = CType(Session("MyClass"), MyClass)

You could make a static class to hold the variables, but you could only have
one user at a time. Then, your code would work without saving the object
off.
 
Y

yop

Ok to be honest I am not sure where they are stored, in
the class.
The class is not been stored in the session. I do not
realise that you could to be honest

thanks

-----Original Message-----
Once you fill the object, where are you storing it? In session? Serialized
to disk? Not at all?

Since you are simply creating a group of
properties/fields a struct might be
 
C

Cowboy \(Gregory A. Beamer\)

When you load a class, it goes out of scope as soon as the page finishes
processing. If you try to pull that class on another page, it has no values,
as it is a new instance.

If you want to use an object across multiple pages, you need to store it
somewhere. Using Session is the easiest method, but you can serialize the
object and create your own engine, if there is some reason session is
unusable. Recreating the wheel is a pain, however, so I would stick to
Session before rewriting the mechanism.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top