473,668 Members | 2,386 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 1616
If your classes aren't extending System.Web.Http Context in some way, they're
not going to have access. You'll notice that your aspx pages extend
System.Web.UI.P age. 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.c om> wrote in message
news:au******** *************** *********@news. supernews.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******@provi ded.com> wrote:
If your classes aren't extending System.Web.Http Context 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
2460
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 happens if one of those objects, when it is created, takes a reference to the object that contains it? Do bad things happen? class McShow {
8
2501
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 multiprotocol, but do not want to write code for all protocols which I want to support. I plan I give a interface and others give a module which implements a protocol, and then the module can be inserted into my program without recompiling my program....
3
9824
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 user interface. how should have get window handle from managed windows? Thanks in advance. Sushil
9
2380
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 any of the response.write lines from inside the sub. ******************************************* <%@ Application Language="VB" %> <script runat="server">
5
10176
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 objFolder=fso.GetFolder("f:\") for each objFile in objFolder.files response.write objFile.name & "<br>" next
6
4868
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 the html page controls the form fields that are required. It doesn't function like it's supposed to and I can leave all the fields blank and it still submits the form. Also I can't get it to transfer the file in the upload section. The file name...
10
4254
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. Because of this, I am unable to store these settings in the App.Config file, as this gets updated every time the application does, and there doesn't appear to be a way of preventing this. Most of my application settings are kept in the...
6
2207
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 following is the main dll file. #include "stdafx.h" #define MAX_ADSPATH_CHARS 2048 //*************************************************************************** // local function prototypes
0
2867
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 http://msdn2.microsoft.com/en-us/library/aa446487.aspx I was able to build the Cab file installer and Setup for the application just fine and I created the CustomInstaller in VB rather than C# in the example.
0
8459
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8791
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
8577
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
8653
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7398
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6206
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4202
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
4376
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2018
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.