473,320 Members | 1,828 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.

Q: define values for all pages

Hello,
In my C# asp.net web application, I need to define a few variable that is
reachable from all pages. If it was C I would define it in the .h file as
struct and use it in the myStruct.myFirstvalie, MyStruct.SecondValue, how
should I do this here in asp.net? I guess I should use class, can you give me
example to handle it.?
Nov 19 '05 #1
2 1002
Create one .cs file with in the project. Define all the variables that are
required all the variables.

Then in the .aspx.cs pages call the variables by creating objects to those
classes.

Eg:
Temp dt = new Temp();
dt.newtest();
string Name = dt.Name;

Where temp is the class created.
"JIM.H." wrote:
Hello,
In my C# asp.net web application, I need to define a few variable that is
reachable from all pages. If it was C I would define it in the .h file as
struct and use it in the myStruct.myFirstvalie, MyStruct.SecondValue, how
should I do this here in asp.net? I guess I should use class, can you give me
example to handle it.?

Nov 19 '05 #2
You got a few options. If you want the scope of the variable to be just the
execution of the page you can place a class in the bin directory (or app_code
in version asp.net2).
That class will be available to all of your asp.net pages and you can make
the varaible static if you don't want to instantiate the class.
You could also make the page class inherit a customized base class so that
it would appear that the variable is 'native' just like the request,response,...
obejct.

If you want that variable to remember its value between page request than
you have to use the session object if you want the scope of the variable
to bo 1 user.
Use the application object if you want the varaible to be seen and modifiable
by all users .

Let me know if you have any more questions..

Cheers,
Tom Pester
Hello,
In my C# asp.net web application, I need to define a few variable that
is
reachable from all pages. If it was C I would define it in the .h file
as
struct and use it in the myStruct.myFirstvalie, MyStruct.SecondValue,
how
should I do this here in asp.net? I guess I should use class, can you
give me
example to handle it.?

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: bart plessers | last post by:
Hello, I am making a website where the user can choose a 'skin'. This works with asp en stylesheets. In the stylesheet, a number of tags are (re)defined. The main idea is to have a limited...
7
by: No Spam | last post by:
----snip #define POSITIVE_INTEGRATOR_SATURATION 0x03000000L // #define NEGATIVE_INTEGRATOR_SATURATION 0xFD000000L // long integrator; integrator=0;
6
by: msigwald | last post by:
The following line of code works, however, since my professor is a real purist of c, I would like to know if this code is valid (is it good code or a piece of crap?): #define DMP_FILE argv ...
5
by: han zhiyang | last post by:
Hi. I tried to design a custom web control which can flexibly and dynamicly let the control user ,for example the web page developer, customize its layout codes.This control derives from...
3
by: iler.ml | last post by:
I am writing code that uses two third-party libraries. They both define same macro OP_ENCRYPT, and luckily for me, they both define it to 0. (In one include, it's '#define OP_ENCRYPT 0', in...
8
by: savvy | last post by:
I have a javascript menu navigation. I have some session values which regularly get updated, but when i navigate using this Javascript menu to a different page i'm not able to see the updated...
1
by: Steve | last post by:
After a few hours of trial and error I have reached the following conclusions, can you please tell me if I am right: I have 2 aspx pages both with the same master page and I wish to pass values...
11
by: Sylvia A. | last post by:
How can I define global classes in web application ? Classes can be set to session variables ? Thanks
9
by: =?Utf-8?B?UGV0ZXJX?= | last post by:
I have a TabControl on a Windows form in which I have various tab pages each with a DataGridView, the first column of which is a DataGridViewCheckBoxColumn and subsequent columns being...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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
0
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....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.