473,839 Members | 1,402 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.myFirs tvalie, MyStruct.Second Value, 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 1019
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.myFirs tvalie, MyStruct.Second Value, 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,respons e,...
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.myFirs tvalie, MyStruct.Second Value,
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
19903
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 number of colors (lets say 4) and use only these colors to color up every tag. However, with a long list of (custom) styles, it is a lot of work to scan
7
1774
by: No Spam | last post by:
----snip #define POSITIVE_INTEGRATOR_SATURATION 0x03000000L // #define NEGATIVE_INTEGRATOR_SATURATION 0xFD000000L // long integrator; integrator=0;
6
1855
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 This would be use to do something like this: void main(int argc,char *argv) { FILE *p2file=fopen(DMP_FILE,"w"); }
5
4243
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 System.Web.UI.Control,and for my purpose,I define a delegate property in the control's class definition, so control user can define his(or her) method out of the class definition and add his(or her) method to the delegate chain. I also override the Render...
3
3098
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 another include it's 0x0). I cannot change contents of those two includes. This generates comipler warning 'macro redefined'. It's easy to suppress the warning with #ifdef. But I want to also cross-check that those two macros have same value. I am...
8
4236
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 session values where I actually need them, i will be getting only the old ones. And when i refresh the page i can see the new values. Is there is way to get around this problem? Can any one help please?
1
2346
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 from one to the other. 1. The postbackurl method doesn't seem to work with master pages. If I take away the master pages it works. 2. The server.transfer method also doesn't work if I try to acess the
11
2358
by: Sylvia A. | last post by:
How can I define global classes in web application ? Classes can be set to session variables ? Thanks
9
10420
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 DataGridViewtextBoxColumns. In each case the properties of the CheckBoxcolumn have been set to not allow nulls, so presumably only explicit true or false values should be possible. I run the application and set check boxes for DataGridView rows I am...
0
9697
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10909
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10588
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10650
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7019
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5682
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4492
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3136
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.