Click to See Complete Forum and Search --> : how to define class object once for entire ASP.NET 2.0 application


prachi001
July 28th, 2008, 12:38 AM
Hello,

I am developing a project in ASP.NET 2.0 and referencing a class from class library in this project. I have defined an object of that class. for example:

Dim eClass1 as new Class1

I want to use this object eClass1 for all the web pages created in ASP.NET project. My first question is where do I define this class, so that it will get initialized only once.

My second question is:

Once I defined this object, I will use class methods using dot operator. For example:

eClass1.Method1()

I want to call Method1 without using class object and dot operator like it was in VB 6.0

For Example:

Method1()

Can you please help me on this?

Thank you.

Shuja Ali
July 28th, 2008, 03:56 AM
Welcome to the Forum :wave:

You have to understand the life time of each object before you start coding like this. Also you have to shelve all you VB6 concepts and learn pure Object Oriented way of programming. You can build a class with Static methods and then call them without instantiating a class however that not be object oriented approach to your problem.