473,396 Members | 1,772 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.

How to get the Global variable Declared in the Global.asax File

12
Hai,
I want to get the Global static name(for Constant) Declared in the Global.asax file for my whole project as a constant.
my coding in the Global.asax file is

private static string strName = "ABCD";
public static string Names
{
get { return strName ; }
}

or is there any way to Declare the Global constant variable for the whole project in asp.net

thanks in advance

Regards,
Babu.k
Nov 20 '08 #1
5 14654
balabaster
797 Expert 512MB
Normally you would declare such things in the web.config. Constants and variables declared in the ASAX file are supposed to be for use only within that file.

If you wish to declare variables that can be accessed outside this file you should declare them as such:

Session("MyVariable") = MyObject

or

Application("MyVariable") = MyObject

Depending on whether you want the variables set at the session level or the application level.

You would then reference them in the same manner from your MASTER/ASPX/ASCX
Nov 20 '08 #2
baburmm
12
Thanks but it does nt works


Normally you would declare such things in the web.config. Constants and variables declared in the ASAX file are supposed to be for use only within that file.

If you wish to declare variables that can be accessed outside this file you should declare them as such:

Session("MyVariable") = MyObject

or

Application("MyVariable") = MyObject

Depending on whether you want the variables set at the session level or the application level.

You would then reference them in the same manner from your MASTER/ASPX/ASCX
Nov 20 '08 #3
r035198x
13,262 8TB
Thanks but it does nt works
Better give a better description than that.
What did you try and what happened when you tried it?
Nov 20 '08 #4
balabaster
797 Expert 512MB
Better give a better description than that.
What did you try and what happened when you tried it?
OP: Are you coding in C# or VB? In C# you'd reference them:

Session["MySessionValue"] = "Some value";

or

Application["MyApplicationValue"] = "Some value";
Nov 20 '08 #5
baburmm
12
Thanks friends it works
OP: Are you coding in C# or VB? In C# you'd reference them:

Session["MySessionValue"] = "Some value";

or

Application["MyApplicationValue"] = "Some value";
Nov 21 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Prince | last post by:
I have a question about the global.asax.cs file. I'm reading info from a database to populate a DataGrid. I read somewhere that the opening of the database should occur in the global.asax.cs...
3
by: hansiman | last post by:
I use Application_Start in global.asax to set some physical folder paths ie.: Application("pdf") = "c:\www\<site>\pdf\" global.asax uses code behind. When I move the project from the dev to...
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...
8
by: Vishwanathan Raman | last post by:
Hi I have a declared a static DataSet object SOBJ in Global.asax.I also have a localy defined DataSet LSOBJ in Global.asax which I am storing in Application State.Is there any technical...
8
by: Thomas Coleman | last post by:
Ok, I've obviously discovered that Global.aspx has been completely changed in ..NET 2.0. However, I haven't figured out how to declare a constant that's available to any page in my application...
4
by: Chris | last post by:
Hi, I want to put the namespaces and the data connection into global.asax like this: <%@ import namespace="System.Data"%> <%@ import namespace="System.Data.OleDb"%> <script runat="server">...
10
by: Yehia A.Salam | last post by:
Hello, I was trying to connect to an Xml database, and I thought of loading the Xml Document in "Application_Start" so that the xml is loaded only once and then queried later as many times as...
15
by: =?Utf-8?B?UGF0Qg==?= | last post by:
Just starting to move to ASP.NET 2.0 and having trouble with the Global.asax code file. In 1.1 I could have a code behind file for the global.asax file. This allow for shared variables of the...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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
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...
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.