Re: Q: define values for all pages

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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.?


.



Relevant Pages

  • Java ServletContext object - any similar object in php?
    ... Is there any equivalent to the Java ServletContext in php? ... like the $_SESSION object but with a larger scope. ...
    (alt.php)
  • Re: Postscript questions
    ... It looks as if you believe the curly braces are defining a scope. ... Curly braces are behaving much more like the square brackets, the array "delimiters". ... The difference is deferred execution, ... Evaluating an executable name means that the interpreter searchs the name through the dictionnary stack and when found, evaluate the value associated with the name. ...
    (comp.lang.postscript)
  • Re: Postscript questions
    ... It looks as if you believe the curly braces are defining a scope ... The difference is deferred execution (and ... A procedure is an executable array. ... Evaluating an executable name means that the interpreter searchs ...
    (comp.lang.postscript)
  • Re: networked printer stops communicating after SBS connection
    ... Scope: * ... 10280 UDP IPv4 ... Disable 3 Allow outbound destination unreachable ... Disable 9 Allow inbound router request ...
    (microsoft.public.windows.server.sbs)
  • Re: Block-level variables in JavaScript
    ... AFAICT ECMA 3rd ed. JavaScript has at least one classical block level ... Scope in javascript is associated with an execution context and its ...
    (comp.lang.javascript)