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

accessing global class from other pages

can anyone imagine why I cannot access static variables in my global class
from other pages, eg:
myNumber = myGlobal.UserID;

where global.asax contains:
<%@ Application Language="C#" Classname="myGlobal" %>
<script runat="server">
public static int UserID = 0;
void Session_Start(Object sender, EventArgs e)
{...}

It doesn't work either using
myNumber = Global.UserID;

btw I'm using .Net 2.0
Nov 19 '05 #1
6 1129
actually I CAN access it using
myString = ASP.myGlobal.Title;

but what's odd is that it's content lives between page cycles so if I do
ASP.myGlobal.Title += "testing... "

and refresh page the string becomes
"testing... testing... testing..." etc!
Nov 19 '05 #2
What happens if you just set myGlobal.Title string :
ASP.myGlobal.Title = "testing2... "

instead of adding to the existing myGlobal.Title string :
ASP.myGlobal.Title += "testing... "

???

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Daves" <db****@simnet.is> wrote in message
news:OP**************@TK2MSFTNGP15.phx.gbl...
actually I CAN access it using
myString = ASP.myGlobal.Title;

but what's odd is that it's content lives between page cycles so if I do
ASP.myGlobal.Title += "testing... "

and refresh page the string becomes
"testing... testing... testing..." etc!

Nov 19 '05 #3
that certainly "cleans" the preexisting string but I need to be able to use
the += in content pages!

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
What happens if you just set myGlobal.Title string :
ASP.myGlobal.Title = "testing2... "

instead of adding to the existing myGlobal.Title string :
ASP.myGlobal.Title += "testing... "

???

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Daves" <db****@simnet.is> wrote in message
news:OP**************@TK2MSFTNGP15.phx.gbl...
actually I CAN access it using
myString = ASP.myGlobal.Title;

but what's odd is that it's content lives between page cycles so if I do
ASP.myGlobal.Title += "testing... "

and refresh page the string becomes
"testing... testing... testing..." etc!


Nov 19 '05 #4
Hello Daves,

I'm guessing that you created the Title field as static. A static field will
be around until the HttpApplication dies.

--
Matt Berther
http://www.mattberther.com
actually I CAN access it using
myString = ASP.myGlobal.Title;
but what's odd is that it's content lives between page cycles so if I
do
ASP.myGlobal.Title += "testing... "
and refresh page the string becomes
"testing... testing... testing..." etc!


Nov 19 '05 #5
that explains!
does that apply to all static fields I would create, not only in
global.asax?

"Matt Berther" <mb******@hotmail.com> wrote in message
news:22***************************@news.microsoft. com...
Hello Daves,

I'm guessing that you created the Title field as static. A static field
will be around until the HttpApplication dies.

--
Matt Berther
http://www.mattberther.com
actually I CAN access it using
myString = ASP.myGlobal.Title;
but what's odd is that it's content lives between page cycles so if I
do
ASP.myGlobal.Title += "testing... "
and refresh page the string becomes
"testing... testing... testing..." etc!


Nov 19 '05 #6
On Mon, 21 Mar 2005 14:51:23 -0000, "Daves" <db****@simnet.is> wrote:
that explains!
does that apply to all static fields I would create, not only in
global.asax?


Yes - all fields marked as static behave the same way.

--
Scott
http://www.OdeToCode.com/blogs/scott/
Nov 19 '05 #7

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

Similar topics

2
by: Earl Teigrob | last post by:
I am programming ASP.NET using C#. I have been accessing static variables accross my entire application but now need to change some of the static variables that are session specific to instance...
22
by: fd123456 | last post by:
Hi Tom ! Sorry about the messy quoting, Google is playing tricks on me at the moment. > Global.asax is where you normally have the Global Application > and Session variables and code to...
2
by: Nathan Sokalski | last post by:
I would like to access variables and functions that I declare in the Global.asax.vb file. However, I am having trouble doing that. What does the declaration have to look like in the Global.asax.vb...
1
by: Nathan Sokalski | last post by:
I would like to access variables and functions that I declare in the Global.asax.vb file. However, I am having trouble doing that. What does the declaration have to look like in the Global.asax.vb...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.