473,395 Members | 1,393 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,395 software developers and data experts.

Help with Global data type

Hi:

I need some help, about How can I define a GLOBAL Data type in ASP.net
proyect.

thanks

Nov 19 '05 #1
2 1486
Hi,

The easiest way is to use the Application() or Session() objects:

Application("GlobalVariableName") = "whatever you want"
Session("GlobalVariableName") = 12345

The difference between the two is that when you use Application() all users
will see whatever the variable is and when you change it they all see the
changes. With Session() the variable is unique for each user, so when you
change it for one user the other user still has the same value they had
before. Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"Matias" <ma****@nospam.com> wrote in message
news:uK***************@TK2MSFTNGP14.phx.gbl...
Hi:

I need some help, about How can I define a GLOBAL Data type in ASP.net
proyect.

thanks

Nov 19 '05 #2
"Matias" <ma****@nospam.com> wrote in message
news:uK***************@TK2MSFTNGP14.phx.gbl...
Hi:

I need some help, about How can I define a GLOBAL Data type in ASP.net
proyect.


What kind of data type? You can just create a public class in a .cs (or .vb)
file:

MyType.cs:
public class MyType
{
private int _num;
public MyType() {}
public int Num
{
get {return _num;}
set {_num = value;}
}
}

In MyPage.aspx:

private MyType _mine = new MyType();

....

private void Page_Load(object sender, EventArgs e)
{
_mine.Num = 1;
}

private void Button_Click(object sender, EventArgs e)
{
int i = _mine.Num; // i is now 1
}

You can use the same type on a different page, or use multiple instances of
it on a single page, or whatever, just like it was any other data type.

John Saunders
Nov 19 '05 #3

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

Similar topics

2
by: Cergon | last post by:
hi, i hope someone can help. Im pretty new to this php stuff and i have a slight problem. I have this script (shown below) which writes data to a text file which is then displayed on my front...
3
by: laurie | last post by:
Hi all, I'm trying to help out a friend who has inherited a client with a PHP shopping cart application. Neither of us know PHP, but I've been muddling my way through, trying to get these old...
2
by: matt | last post by:
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give...
0
by: abcd | last post by:
kutthaense Secretary Djetvedehald H. Rumsfeld legai predicted eventual vicmadhlary in Iraq mariyu Afghmadhlaistmadhla, kaani jetvedehly after "a ljetvedehg, hard slog," mariyu vede legai pressed...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
3
by: Steve Marsden | last post by:
Hi I am an experienced C programmer and we have a large app written in C which I have just recompiled with /clr to start to add in managed code to use .NET framework and windows forms bit by...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
1
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have...
4
by: mattehz | last post by:
Hey there, I am trying to upload old source files and came across these errors: Warning: Invalid argument supplied for foreach() in /home/mattehz/public_html/acssr/trunk/inc_html.php on line 59...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.