I have a utilities class in my ASP.Net application that encapsulates
functions that I use often. I would like to use this class to access some
object that I have acces to on a page, like Request, Response, and
Application... is there any way for me to access these without having to
pass them in a parameters to my functions?
Thanks,
-Cliff 4 1188
if you don't want them as parameters, put them in the class constructor as a
parameter. When your class instantiates, you save references to these
objects. You should realize from here that saving references to intrinsic
ASP.NET objects is not a good idea at all. I'd stick with passing parameters
if I were you.
--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Cliff Harris" <he***@myrealbox.com> wrote in message
news:OH**************@TK2MSFTNGP12.phx.gbl... I have a utilities class in my ASP.Net application that encapsulates functions that I use often. I would like to use this class to access some object that I have acces to on a page, like Request, Response, and Application... is there any way for me to access these without having to pass them in a parameters to my functions?
Thanks, -Cliff
the best way is:
1) derive a class from Page
2) add member function, property, etc... to this class
3) derive all your WebForm from this page
Enjoy.
Brun
"Cliff Harris" <he***@myrealbox.com> wrote in message
news:OH**************@TK2MSFTNGP12.phx.gbl... I have a utilities class in my ASP.Net application that encapsulates functions that I use often. I would like to use this class to access some object that I have acces to on a page, like Request, Response, and Application... is there any way for me to access these without having to pass them in a parameters to my functions?
Thanks, -Cliff
I guess I forgot to mention a key part of this... this class has nothing but
static members... I never instantiate it....
From the sound of things, it looks like I'd be wise just passing things in
as parameters...
Thanks for the help,
-Cliff
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:u7**************@TK2MSFTNGP10.phx.gbl... if you don't want them as parameters, put them in the class constructor as
a parameter. When your class instantiates, you save references to these objects. You should realize from here that saving references to intrinsic ASP.NET objects is not a good idea at all. I'd stick with passing
parameters if I were you.
-- Regards, Alvin Bruney [ASP.NET MVP] Got tidbits? Get it here... http://tinyurl.com/27cok "Cliff Harris" <he***@myrealbox.com> wrote in message news:OH**************@TK2MSFTNGP12.phx.gbl...I have a utilities class in my ASP.Net application that encapsulates functions that I use often. I would like to use this class to access
some object that I have acces to on a page, like Request, Response, and Application... is there any way for me to access these without having to pass them in a parameters to my functions?
Thanks, -Cliff
You can access it like,
httpcontext.Current.session or httpcontext.current.request
--
Saravana
Microsoft MVP - ASP.NET www.extremeexperts.com
"Cliff Harris" <he***@myrealbox.com> wrote in message
news:OH**************@TK2MSFTNGP12.phx.gbl... I have a utilities class in my ASP.Net application that encapsulates functions that I use often. I would like to use this class to access some object that I have acces to on a page, like Request, Response, and Application... is there any way for me to access these without having to pass them in a parameters to my functions?
Thanks, -Cliff
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: goermezer |
last post by:
Hello,
I have some problems to automate a CAD (computer aided design) Software called
CATIA V5 from Dassault Systemes.
CATIA V5 has a builtin VB-Editor like Word, Excel, … and registers itself...
|
by: andreas |
last post by:
Hi there,
I have the following situation:
1. DOT.NET Application is started
2. DOT.NET Application instantiates Access.Application.8
3. Opens a specified database (MDB)
4. DOT.NET...
|
by: dog |
last post by:
I've seen plenty of articles on this topic but none of them have been
able to solve my problem.
I am working with an Access 97 database on an NT4.0 machine, which has
many Access reports.
I...
|
by: Grasshopper |
last post by:
Hi,
I am automating Access reports to PDF using PDF Writer 6.0. I've
created a DTS package to run the reports and schedule a job to run this
DTS package. If I PC Anywhere into the server on...
|
by: Andrew Dowding |
last post by:
Hi Everybody,
I have been looking at problems with my Windows Forms C# application
and it's little Jet 4 (Access) database for the last few days. The
Windows Forms app implements a facade and...
|
by: SteveS |
last post by:
Hello All. I have an asp.net application with 3 different assemblies. They
are like this:
1) Assembly: PublicSite (This contains the website UI)
Root namespace: PublicSite
2) Assembly:...
|
by: Patrick |
last post by:
I have the following code, which regardless which works fine and logs to the
EventViewer regardless of whether
<processModel/> section of machine.config is set to username="SYSTEM" or
"machine"
...
|
by: lars.uffmann |
last post by:
Hey everyone!
I am (still) working on a project that I took over from former
students, so don't blame me for the criminal approach on coding *g*
The problem I have is fairly easy and while I...
|
by: Lyle Fairfield |
last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/callnetfrcom.asp
The Joy of Interoperability
Sometimes a revolution in programming forces you to abandon all...
|
by: Wesley Peace |
last post by:
I hate to cross post, but I've gotten no answer yet on a problem I'm having
with visual studio 2008.
I've created a series of forms with controls to access a Access database
tables. The...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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,...
| |