473,320 Members | 1,802 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.

Problems with public variables

Hi everyone,

I'm trying to use public variables in a web form to hld specific values.
What happens is that the public variables (declared as public x as y in the
beginning of the class), doesn't seem to hold the value from function call
to function call.

Does anyone can help me abou this?

best regards

JM
Jul 21 '05 #1
2 1697
They won't, every time a postback occurs on the page, they'll be reset.
Using Public Variables in any context isn't probably a good idea...you can
use a class in general with Static or shared properties depending on your
prog language. However, in ASP.NET, a module for instance will be shared
among ALL Users which is seldom desireable.

Instead, store things in Session Variables. They give you the same effect
as public, are isolated to the session and can be strongly typed. The best
of all worlds.

Session("SomeNameForAVariable") = someObject

Dim someNewObject as someObject
someNewObject = CTYpe(Session("SomeNameForAVariable"), someObject)

You can hit this from any page in your app.
HTH,

Bill
"Jose Meireles" <jm*******@myconnections.biz> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Hi everyone,

I'm trying to use public variables in a web form to hld specific values.
What happens is that the public variables (declared as public x as y in the beginning of the class), doesn't seem to hold the value from function call
to function call.

Does anyone can help me abou this?

best regards

JM

Jul 21 '05 #2
Thanks for your anwer Bill,

I've solve my problem using public variables in a module but I wasn't aware
about the fact the public or shared variables in a class/module would be
shared across the entire application (for every sessions). Thats an
important issue to consider.

Thanks again

Jose

"William Ryan" <do********@comcast.nospam.net> wrote in message
news:u8*************@TK2MSFTNGP11.phx.gbl...
They won't, every time a postback occurs on the page, they'll be reset.
Using Public Variables in any context isn't probably a good idea...you can
use a class in general with Static or shared properties depending on your
prog language. However, in ASP.NET, a module for instance will be shared
among ALL Users which is seldom desireable.

Instead, store things in Session Variables. They give you the same effect
as public, are isolated to the session and can be strongly typed. The best of all worlds.

Session("SomeNameForAVariable") = someObject

Dim someNewObject as someObject
someNewObject = CTYpe(Session("SomeNameForAVariable"), someObject)

You can hit this from any page in your app.
HTH,

Bill
"Jose Meireles" <jm*******@myconnections.biz> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Hi everyone,

I'm trying to use public variables in a web form to hld specific values.
What happens is that the public variables (declared as public x as y in

the
beginning of the class), doesn't seem to hold the value from function call to function call.

Does anyone can help me abou this?

best regards

JM


Jul 21 '05 #3

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

Similar topics

7
by: isaphrael | last post by:
I am in a situation where my supervisor doesn't want the mdb split into front end and back ends, as he sees it as being impractical. I also see it as being impractical, as it will only recieve...
0
by: Gastin | last post by:
I am digesting a web serivce from Amazon.Com. I have the following class which was autogenerated by VS.NET when I created a Web Reference to...
4
by: Charles | last post by:
I am still having problems with sessions crossing over from other sessions. What I mean by this is that Mary may get just some or all of Renae’s information. I think that what is going on with...
2
by: John Mullin | last post by:
We are having a problem which appears similar to a previous posting: http://groups.google.com/groups?hl=en&lr=&frame=right&th=d97f552e10f8c94c&seekm=OZw33z9EDHA.2312%40TK2MSFTNGP10.phx.gbl#link1 ...
6
by: Don | last post by:
I'm having problems working with a streamwriter object. After closing the streamwriter and setting it to Nothing, I try to delete the file it was writing to, but I always get the following error...
4
by: Nick Dreyer | last post by:
Is it possible to see public class variables of a COM addin in Excel 97 VBA? I have successfully created the (Visual Basic 2003 .NET) COM and referenced it in an Excel 97 VBA project. The VBA...
2
by: Jose Meireles | last post by:
Hi everyone, I'm trying to use public variables in a web form to hld specific values. What happens is that the public variables (declared as public x as y in the beginning of the class), doesn't...
20
by: Aek | last post by:
We recently moved our large codebase over from VS7 to 8 and found that we now get access violations in atexit calls at shutdown when debugging the application in VS2005. This occurs in static...
10
by: Cliff | last post by:
Greetings, I have been trying to teach myself C++ over the past few weeks and have finally came across a problem I could not fix. I made a simple program that prints out a square or rectangle...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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)...
0
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.