Solved

page_load and constructor

Posted on 2003-11-09
7
755 Views
Last Modified: 2012-05-04
What's wrong with the following? Does page_load by default call a constructor implicitly? Where is the constructor of the class?

private page_load (...)
{
  new Constructor();
}

public Constructor()
{
   .......
}


Thanks.


0
Comment
Question by:samliam
  • 2
7 Comments
 
LVL 1

Expert Comment

by:brabchev
Comment Utility
What do you mean?
Be more specific and post a whole class.
0
 
LVL 6

Expert Comment

by:purpleblob
Comment Utility
I'm making assumptions here such as you've removed the class declaration and returntypes etc., but assuming these things. What appears to be happening is that page_load is a method which instantiates a class called Constructor, it doesn't keep a reference to the instance so I would assume everything is mean't to happen would happen in the class Constructor's constructor. Now Assuming that your second declaration is mean't to be a class (but no class keyword is shown so this is an assumption) and also assuming you've not supplied a constructor what happens is that a default one is supplied for you implicitly.

Obviously these assumption would mean that as you're not deriving from a base class which supplies a default constructor that in fact all that will happen in this code is it'll create an instance of Constructor then throw the instance away until it's garbage collected.

Not sure if this helps, feel free to clarify if you need further info.
0
 
LVL 10

Accepted Solution

by:
ptmcomp earned 50 total points
Comment Utility
Page_Load is an event handler. When it's called the page object is already created.
There is a request handler that constructs the page object this is outside of the Page class.

You can find more information here: http://www.15seconds.com/issue/020102.htm
0
 
LVL 10

Expert Comment

by:ptmcomp
Comment Utility
public Constructor() - this looks like a mixing up object pascal with C#. A contructor has always the name of the class:

class MyClass
{
    // constructor
    public MyClass()
    {
    }
}
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: Ivo
Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now