473,399 Members | 2,159 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,399 software developers and data experts.

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

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.
Nov 22 '05 #1
2 1142
how about putting it into the session, and retrieving it from Session when
you need it?

http://samples.gotdotnet.com/quickst...x#sessionstate

-Dino

--
Dino Chiesa
Microsoft Developer Division
d i n o c h @ o n l i n e . m i c r o s o f t . c o m
"re**************@nospam.com" <se*@website.com> wrote in message
news:ot********************************@4ax.com...
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.

Nov 22 '05 #2
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!
On Thu, 13 Nov 2003 11:26:17 -0500, "Dino Chiesa [Microsoft]"
<di****@online.microsoft.com> wrote:
how about putting it into the session, and retrieving it from Session when
you need it?

http://samples.gotdotnet.com/quickst...x#sessionstate

-Dino


Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: Daniel | last post by:
Hello =) I have an object which contains a method that should execute every x ms. I can use setInterval inside the object construct like this - self.setInterval('ObjectName.methodName()',...
2
by: refer_to_website | last post by:
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...
8
by: TTroy | last post by:
I have a few questions about "scope" and "visibility," which seem like two different things. To me "visibility" of the name of a function or object is the actual code that can use it in an...
15
by: randyr | last post by:
I am developing an asp.net app based on a previous asp application. in the asp applications global.asa file I had several <object id="id" runat="server" scope="scope" class="comclass"> tags for...
11
by: Kevin Prichard | last post by:
Hi all, I've recently been following the object-oriented techiques discussed here and have been testing them for use in a web application. There is problem that I'd like to discuss with you...
4
by: Anthony England | last post by:
This is a simple question, which has been debated before, but can I ask it again with reference to a specific example? The question is basically should I close and set to nothing an ADO connection...
26
by: yb | last post by:
Hi, Is there a standard for the global 'window' object in browsers? For example, it supports methods such as setInterval and clearInterval, and several others. I know that w3c standardized...
1
by: Steven T. Hatton | last post by:
All of the following terms are used in some way to describe where and how a name is relevant to a particular location in a program: visible, declarative region, scope, potential scope, valid,...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
2
by: Constantine AI | last post by:
Hi i have created a Sales Order Header with a Sales Order Line (1 to many relationship) See Picture for image of error! I receive this error when inputting data into the sfrmSOHeader in Add mode. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.