473,509 Members | 8,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't access application object from inside class files

I added a couple of class files to a VS web project, and I can't access
the application object from inside them. The system treats them like
undeclared variables. Is there an Imports I have to use?

The value that I need global to the entire project is the oleDB
connection string ("Provider=.... Data Source=C:\...").

What I've done in the meanwhile is declare a shared property in each of
the classes to hold this value. When the application starts, I set the
property from the global.asax.vb file. This works, but is it a real
hack?

Is there a better way to establish global constants in VS web projects?

Nov 18 '05 #1
2 1612
If your classes aren't extending System.Web.HttpContext in some way, they're
not going to have access. You'll notice that your aspx pages extend
System.Web.UI.Page. Page has an HttpContext, which means that your
codebehind classes have access. on the other hand, classes that you add
yourself won't have automagic access.

as for the "best" way to have a global constant - I'll let someone else with
more experience than I take a stab at the "best" way to accomplish that.

John

"tr****@sirius.com.no.more" <us**@example.com> wrote in message
news:au********************************@news.super news.com...
I added a couple of class files to a VS web project, and I can't access
the application object from inside them. The system treats them like
undeclared variables. Is there an Imports I have to use?

The value that I need global to the entire project is the oleDB
connection string ("Provider=.... Data Source=C:\...").

What I've done in the meanwhile is declare a shared property in each of
the classes to hold this value. When the application starts, I set the
property from the global.asax.vb file. This works, but is it a real
hack?

Is there a better way to establish global constants in VS web projects?
Nov 18 '05 #2
"John Ruiz" <no******@provided.com> wrote:
If your classes aren't extending System.Web.HttpContext in some way, they're
not going to have access. You'll notice that your aspx pages extend
System.Web.UI.Page. Page has an HttpContext, which means that your
codebehind classes have access. on the other hand, classes that you add
yourself won't have automagic access.


Thanks for the explanation. Now I know a little more!
Nov 18 '05 #3

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

Similar topics

6
2454
by: lawrence | last post by:
How dangerous or stupid is it for an object to have a reference to the object which contains it? If I have a class called $controllerForAll which has an arrray of all the objects that exist, what...
8
2492
by: Zheng Da | last post by:
I don't know where should I ask the question, so send the email to this group. I choose this group, because I want to write the program with c++ :) I want to write a program which support...
3
9812
by: Sushil Srivastava | last post by:
Hi Guys, Would you be able to help me using C# GUI (with user interface component) in my MFC application. I have used managed extension, COM-interops, etc but problem is this C# component has...
9
2364
by: tshad | last post by:
I have an example I copied from "programming asp.net" (o'reilly) and can't seem to get the Sub (writefile) to execute. It displays all the response.write lines that are called directly, but not...
5
10161
by: Josh Rolfe | last post by:
I have a page in classic asp that accces a network drive, The code is as follows: <% dim fso dim objFolder set fso=server.createObject("Scripting.FileSystemObject") set...
6
4842
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
10
4234
by: Paul Cheetham | last post by:
Hi, I am developing an application that needs to store some machine-specific settings. The application is going to be published on the network in order to keep the clients on the latest version....
6
2199
by: Pucca | last post by:
I have a program that originally compiles into a exe file. I changed the compile option to generate dll file. This program calls a com component. Can I use pinvoke in C# to call it? The...
0
2842
by: Andrzej Lipski | last post by:
Hello I am developing a Windows Ce 5.0 mobile application. I followed the example shown at : Creating Self-Updating Applications With the .NET Compact Framework...
0
7237
marktang
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,...
0
7347
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,...
0
7416
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...
1
7073
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...
0
7506
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5062
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3218
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...
0
1571
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 ...
0
443
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...

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.