CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2008
    Posts
    29

    Question how to define class object once for entire ASP.NET 2.0 application

    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.
    Last edited by prachi001; July 28th, 2008 at 12:40 AM. Reason: Incomplete Title

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: how to define class object once for entire ASP.NET 2.0 application

    Welcome to the Forum

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured