By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,805 Members | 1,652 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,805 IT Pros & Developers. It's quick & easy.

Variable & storing

P: n/a
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
Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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!
************************************************** **************************
****
"yop" <ai*******@oceanfree.net> wrote in message
news:06****************************@phx.gbl...
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

Nov 17 '05 #2

P: n/a
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? Serializedto disk? Not at all?

Since you are simply creating a group of properties/fields a struct might bea 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 haveone user at a time. Then, your code would work without saving the objectoff.

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

************************************************* ******** ***********************
Think Outside the Box!
************************************************* ******** ***********************
"yop" <ai*******@oceanfree.net> wrote in message
news:06****************************@phx.gbl...
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

.

Nov 17 '05 #3

P: n/a
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!
************************************************** **************************
****
"yop" <ai*******@oceanfree.net> wrote in message
news:0b****************************@phx.gbl...
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
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!
************************************************* ********

*******************
****
"yop" <ai*******@oceanfree.net> wrote in message
news:06****************************@phx.gbl...
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

.

Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.