Variable & storing

  • Thread starter Thread starter yop
  • Start date Start date
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
 
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.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
Author: ADO.NET and XML: ASP.NET on the Edge

****************************************************************************
****
Think Outside the Box!
****************************************************************************
****
 
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
 
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.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
Author: ADO.NET and XML: ASP.NET on the Edge

****************************************************************************
****
Think Outside the Box!
****************************************************************************
****
 
Back
Top