473,320 Members | 2,107 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,320 software developers and data experts.

Global Variable declaration?

Is there a way of declaring a global variable in a masterpage that can be accessed from every aspx page the masterpage is linked to?
Thanks
Oct 1 '07 #1
4 1203
shweta123
692 Expert 512MB
Hi,

You can store the value of Request.Cookies("Admin")("SupplierID")
in Session to make it global.

e.g. Session("AdminSupplierId") = Request.Cookies("Admin")("SupplierID")



Is there a way of declaring a global variable in a masterpage that can be accessed from every aspx page the masterpage is linked to?
Thanks
Oct 1 '07 #2
Hi,

You can store the value of Request.Cookies("Admin")("SupplierID")
in Session to make it global.

e.g. Session("AdminSupplierId") = Request.Cookies("Admin")("SupplierID")

Yeah i would have used that, but the project unfortunately (for me) requires a global variable instead of a session, cookie etc..
Just wondering if this is indeed possible.

Thanks again
Oct 1 '07 #3
Shashi Sadasivan
1,435 Expert 1GB
Yeah i would have used that, but the project unfortunately (for me) requires a global variable instead of a session, cookie etc..
Just wondering if this is indeed possible.

Thanks again
Have you tried creating ab ase class for the master page to inherit from which contains a static variable of your intended "global" variable.

I am not sure if this would work for web apps, but Sessions seem to be the best bet.

cheers
Oct 1 '07 #4
shweta123
692 Expert 512MB
Hi,

You can also try viewstate , syntax is similar to sessions.

Or declare a class and property inside it which will return the value you want.

e.g.

Public Class Globals
Public ReadOnly Property getID() As int
...........
End Property
End class




Have you tried creating ab ase class for the master page to inherit from which contains a static variable of your intended "global" variable.

I am not sure if this would work for web apps, but Sessions seem to be the best bet.

cheers
Oct 1 '07 #5

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

Similar topics

0
by: Joseph George | last post by:
How do I hold a global variable in VB.NET? I am creating as ASP web form like this: Public Class WebForm1 Inherits System.Web.UI.Page Dim list as new ListItemCollection() - - - Private Sub...
3
by: Eric Lilja | last post by:
Hello, I have a few global variables in my program. One of them holds the name of the application and it's defined in a header file globals.hpp (and the point of definition also happen to be the...
2
by: Thomas Matthews | last post by:
Hi, I'm getting linking errors when I declare a variable in the global scope, but not inside a function. The declarations are the same (only the names have been changed...). class Book {...
6
by: rick | last post by:
Noob problem. I prefer to keep all my scripts in an external '.js' file. I am currently loading the external '.js' file from the header. Problem is I would like to declare a global variable in the...
17
by: MLH | last post by:
A97 Topic: If there is a way to preserve the values assigned to global variables when an untrapped runtime error occurs? I don't think there is, but I thought I'd ask. During development, I'm...
44
by: fabio | last post by:
Why? i' ve heard about this, the usage of global vars instead of locals is discouraged, but why? thx :)
16
by: Roman Ziak | last post by:
Hello, there were times when I used to be looking for a way to access JavaScript Global object similar to those found in VBScript or PHP ($GLOBALS). At present this has only academic value for...
4
by: kuhrty | last post by:
I am using a window form and trying to get a dataset used in the form globally but I am having an issue setting the property and setting it locally to the class. When I try to call the dataset...
4
by: the_init | last post by:
Hi friends, Can you please explain me why the following code prints 10, instead of 20 - Here I am little confused with the static and global declaration of i in the same program. ...
112
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.