global declaration of variables

Hi all,

As i'm new to asp.net,kindly help me in the following problem.
I want to declare a global variable to make use of it in mutliple webforms.
Currently i declared in global.asax file at Sub Session_Start.
Is this the standard way of declaring a global variable.
Please advice.
Thanks in advance,
ragyari.
0
ragyari
12/8/2004 10:14:07 AM
asp.net.getting-started 91979 articles. 4 followers. Follow

3 Replies
452 Views

Similar Articles

[PageSpeed] 34
Get it on Google Play
Get it on Apple App Store

Hello,

Unique to the user? Use a session variable.
Brian
Brian

"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4).
0
bmains
12/8/2004 12:34:20 PM
Right, or a truly global var would be used at Application scope, so use an Application var.
In this world there are 10 types of people, those that know binary and those who don't.
0
optik
12/8/2004 1:12:47 PM
Session items are specific to a particular user and span pages.

Session(yourKey) = someObject
Application items are shared by all users
Application(yourKey) = someObject
Cache items are also shared by all users but give you flexibility in expiring each item.
Cache.Add(...)
If you using VB.NET and are looking for an Application scoped variable, then you should use a public variable declared in a Module outside of any Class. According to the MS docs, this is faster than using an Application item.

When using application scoped variables, always stay conscious of threading issues.
i.e. two users updating the var at the same time...
Mike Banavige
~~~~~~~~~~~~

Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/
0
mbanavige
12/8/2004 1:31:28 PM
Reply:

Similar Artilces:

Get Latest Version doesn't get Global Variable Declarations
We are using PB Native SCC. I am able to successfully Get Latest Version on all of our objects except it does not get changes made to the global variable declarations. I would expect that you need to make a trivial change to the application object (add a blank line to a script) and check it in, and make sure that is part of the package that each developer gets as part of the GLV (it shows as being X-ed off). It may be that GLV imports the object referring to the global first, then that regen fails with an error message, and finally it imports the application where the globals ...

How do you declare a GLOBAL variable in VB.net
Does anyone know how to do this?  Thanks, NewKid Global variables in .net 2.0 dont really exist the way they used to in C++ for example, because you dont have a single instance class running.  If you are in the ASP.NET model, you can use the global.asax file to declare a Public or Public Shared variable, or you can use Sessions as your global variable holder. If you are in a VB model for win forms, Your best bet is to declare a class, and put a public member in it that will hold your value, and instanciate it when the application starts.Bryan SampicaAuction Site StarterKit |M...

Global variable declaration in vb.net winforms
Hi all Can anyone please tell how to declare global variable in winform. I want to declare one variable at start of a application and use in different form. eg. i want to store userid/usertype and check in each form this variable across the application. Also please tell me how to use in each form Thanks in advance Rashid Windows Forms forums at http://forums.microsoft.com is more suitable place to ask WinForm related questionsThanks,Teemu KeiskiFinland, EU With Visual Basic, it's fairly easy to create global variables in winforms.  Modules are the usual method.  As long as it...

Declaring Global Variables and Global External Function By PowerScript
Does anyone can tell me, can I declare the global external function / global Variables by PowerScript ( such as, within the application's open event ), not in 'declare painter' ??? Thanks Samkola No. They need to be declared within the Global Variables painter. Ron Gallagher, CPDP Atlanta, GA rongallagher@mindspring.com samkola wrote in message <01beee19$8715d2a0$2d01a8c0@testing>... >Does anyone can tell me, can I declare the global external function / >global Variables by PowerScript ( such as, within the application's open >event ), not i...

Quickie question: Declaring a global-level variable with Global.asax
My instructor told me it might be best to create an SQL connection in global.asax instead of making new connections for every form I create. However, when I declare the variable in Session_Start, it still doesn't see the variable on the other form I have. Obviously there is something I'm not getting here. So my question might sound trite, but I simply need to create an SQL connection variable that can be accessed from any of my .aspx pages. Any takers? Your professor does not understand ASP.NET and connection pooling. Creating a single connection in Global.asax and using it on ...

Global Variables vs. instance variables declared at application object level
There is only one application object instance during the application runtime that is instantiated at the start along with the global variables, so I am looking for what are the major differences, advantages , and disadvantages between Global Variables and instance variables declared for the application object. Thanks I've wondered also about the application instance variables. I think the difference with global vars is very subtle. Maybe too subtle to be of any use. Anyway, you shouldn't be using either one of them :-) Geert 'Darling' Van Damme Moh...

how to get start with .NET
the net help people installed  to my desktop 1-microsoft visual studio .NET enterprise developer 2003 2-microsoft .NET framework 1.1 what else do i need ...???  and how can i try with some simple code in VS.Net and run it to see wat happen...????? please help If you want to develope web applications, then you'll also need IIS on your PC.  That'll require XP-Professional or Windows 2000/2003, but XP-Home edition won't allow IIS installation. As for how to get started, you can search the web for some tutorials or buy a good book on VS.  The topic is way too vast to...

declaring global variables
Partial Class _Default    Inherits System.Web.UI.Page    Private nvers As Integer    Private nid As Integer    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load        If Not IsPostBack Then             nid = 0        End If    End Sub     Protected Sub NewVer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles NewVer...

How and where to declare a global variable??
hi.. i am doing a project for my final year.. but i am stuck.. pls help... i am using .NET and have a lot of webforms.. i wan to store txtID.TEXT (which is an integer)in log in page into a variable so that after it log in and goes to another webform, i can use the txtID.Text from the login webform to retrieve the data from my data base.. how am i going to go about doing it?? please help.. where sld i declare the global variable and how?? izzit Public ID as Integer??? thank you.. Probably the best place would be in the session, as this is specific to the user browser so each...

Declaring a global variable
How does one go about declaring a global variable?   You don't. Not that it's impossible, but it's a thing mostly used in non object oriented architectures, and it's usually not suitable. The closest thing is to declare a static member on a classpublic class SomeClass{   public static string SomeValue="The Value";} which will then be accessible as SomeClass.SomeValue -- "Mark As Answer" if my reply helped you --  you can define global variables with Static keyword in C# within a class as..Public Static String strCurru...

declaring a global variable
Hello!   How do you declare a global variable in dot net 2005.    Kind regardssaxenaharsh if u mean global respect to your page/class u can declare it just after class opening if u want something shared in all pages u can use session variables.Contact me on Skype Please notice where you have to declare your global variable:Partial Class _Default    Inherits System.Web.UI.Page    Protected myGlobalVar As Integer    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load    E...

Declaring a variable as global
How do I declare a variable that is made available to all forms please I cannot see an example in the help files Cheers SteveW In the declaration tab, in the top middle of the window there will be another pull down. Here you can specify global variables (as well as instance variables.) HTH, chance. "SteveW" <Stevewarby@btinternet.com> wrote in message news:46c45019$1@forums-1-dub... > How do I declare a variable that is made available to all forms please > > I cannot see an example in the help files > > Cheers > > SteveW ...

Declaring Global Variables
Where do I declare a global variable now? I can't find the page class (where I used to place things like PUBLIC/SHARED myVariable as Integer=0 I am trying to do some basic stuff, but everytime my page loads it redims my variables... -Taking a long walk off of a short peer...C# or VB it's all the same to me.Carolus HolmanTurner Corporation To avoid loosing data on page reloads use viewstate I'm afraid this post is in VB not in C# but, take a look on this post http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=592165 For more information about the use of viewstate ...

global variable declaration
I am using VS 2005. Could you please let me know where should I declare the global variable so that I can access it's value accrross the site.   Thanks   If your looking for a "global" variable, then inside a class, you'd put a variable outside of any subs or functions Public Class TestingClass Dim MyString as String I caution you though, that global variables like this will be shared across all users of your site.  So if one user sets the variable to something specific, it will be set for another user already - your going to run into huge concurancy issues.  It's...

Web resources about - global declaration of variables - asp.net.getting-started

United States Declaration of Independence - Wikipedia, the free encyclopedia
"Declaration of Independence" redirects here. For the type of document generally, see Declaration of independence . For the painting, see Trumbull's ...

United States Declaration of Independence - Wikipedia, the free encyclopedia
"Declaration of Independence" redirects here. For the type of document generally, see Declaration of independence . For the painting, see Trumbull's ...

ISIS is taunting Anonymous with a declaration of 'war'
... with ISIS has... A propaganda account affiliated with ISIS has released another statement related to the hacking collective Anonymous’ declaration ...

Australia v New Zealand second Test: Centuries for Steve Smith, Adam Voges as declaration looms on final ...
The trickle of wickets in Perth across the first four days of the second Test has left the chance of a result resting on the instructions and ...

A Virginia school district shut down today after parents raged about an assignment to copy the Muslim ...
... of calligraphy," but the text, in Arabic, was "There is no God but God, and Muhammad is the messenger of God" — the shehada (or declaration ...

Ultra-Orthodox declaration on homosexuality disappears
Jewish newspaper Haaretz has noted that an ultra-orthodox statement on homosexuality has disappeared The Torah Declaration, the paper that outlines ...

ISIS is 'trying to taunt' Anonymous with a new statement on the hackers' declaration of 'war'
A propaganda account affiliated with ISIS has released another statement related to the hacking collective Anonymous' declaration of "war" on ...

No joint declaration at Asia defense meet amid sea tensions
Chron.com No joint declaration at Asia defense meet amid sea tensions Chron.com KUALA LUMPUR, Malaysia (AP) — Divisions within Asia over China's ...

French Politicians Sing Out War Declaration Against Enemies Who ‘Cut The Throats Of Your Sons’
French Politicians Sing Out War Declaration Against Enemies Who ‘Cut The Throats Of Your Sons’

Los Angeles to extend shelter program for homeless, fall short of emergency declaration
Los Angeles to extend shelter program for homeless, fall short of emergency declaration

Resources last updated: 1/3/2016 1:07:39 AM