469,342 Members | 5,664 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,342 developers. It's quick & easy.

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 14380
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

Post your reply

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

Similar topics

6 posts views Thread by Prince | last post: by
3 posts views Thread by hansiman | last post: by
22 posts views Thread by fd123456 | last post: by
2 posts views Thread by Nathan Sokalski | last post: by
8 posts views Thread by Vishwanathan Raman | last post: by
8 posts views Thread by Thomas Coleman | last post: by
4 posts views Thread by Chris | last post: by
10 posts views Thread by Yehia A.Salam | last post: by
15 posts views Thread by =?Utf-8?B?UGF0Qg==?= | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.