Datahighway Posted December 6, 2003 Posted December 6, 2003 Hi All , i have a trouble with unterstanding the global variable in ASP.Net. How can i set a globale variable. (Property doesn*t work) I must use different function wiht the same variable. Maybe can post someone a exsample for me. Thanks and best Regards Datahighway Quote
bungpeng Posted December 6, 2003 Posted December 6, 2003 You can search the answer in this forum. You can just cookies or session to do that Quote
fadi Posted December 8, 2003 Posted December 8, 2003 there is no global variables in asp.net, u should use sessions in this case, but do this carefully since its memory consuming Quote
Shirtster Posted December 8, 2003 Posted December 8, 2003 You could create a new class and add your "global variable" as a static member, or add it as a static member of global.asax instead Quote
fadi Posted December 8, 2003 Posted December 8, 2003 but i dont think this would help bc i guess the variable will lose its value across postbacks Quote
Shirtster Posted December 16, 2003 Posted December 16, 2003 use an Application variable then. Sessions aren't "global" across the application Quote
zubie Posted December 16, 2003 Posted December 16, 2003 You can also create a module (I use Global as the name) Then have something like this Module Global Friend intFunction as integer = 0 This will give you a global variable that can be changed. Hope this helps ZuBiE Quote
bungpeng Posted December 16, 2003 Posted December 16, 2003 I thought Module is not recommended in .NET? due to not object oriented concept? Quote
zubie Posted December 18, 2003 Posted December 18, 2003 Hmmm it may not be recommended but I didnt know that until now :) Using it worked for me !!! Quote
bungpeng Posted December 18, 2003 Posted December 18, 2003 If it is fine for you, then use it... :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.