473,320 Members | 1,766 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,320 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 1139
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.