473,378 Members | 1,564 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Variable & storing

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
3 1424
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Bill | last post by:
For my personal use I am accessing a railway timetable page, parsing its contents and then sending brief relevant information as the subject line of an email to be read on a mobile phone. The...
2
by: Fan of P2P | last post by:
Hi, Does anyone know how I can store files (mostly pictures) into a mySQL table? I have tried the load_file function but it seems to not work. i just get NULL as the value. Any examples...
27
by: Daniel Vallstrom | last post by:
I'm having problems with inconsistent floating point behavior resulting in e.g. assert( x > 0.0 && putchar('\n') && x == 0.0 ); holding. (Actually, my problem is the dual one where I get...
7
by: Greg Collins [MVP] | last post by:
Hi, I couldn't find what I was looking for by searching the newsgroup, but perhaps these have already been discussed somewhere. This is a bit long with a lot of interrelated questions. What I've...
41
by: Miguel Dias Moura | last post by:
Hello, I am working on an ASP.NET / VB page and I created a variable "query": Sub Page_Load(sender As Object, e As System.EventArgs) Dim query as String = String.Empty ... query =...
1
by: Martin Widmer | last post by:
Hi guys I am wondering what is a proper way to persistently store objects into SQL-Server. I see four possible ways: 1.) Serialize to XML and then store the XML in the SQL server 2.) Write a...
11
by: Jeremy | last post by:
How can one stop a browser from converting &amp; to & ? We have a textarea in our system wehre a user can type in some html code and have it saved to the database. When the data is retireved...
3
by: Markus Schuster | last post by:
Hi, I have the following javascript function: <script type="text/javascript"> function HTMLEncode( text ) { text = text.replace(/&/g, "&amp;") ; text = text.replace(/"/g, "&quot;") ;
3
by: RSH | last post by:
Hi, I have a situation where I have created an object that contains fields,properties and functions. After creating the object I attempted to assign it to a session variable so i could retrieve...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.