Solved

page_load and constructor

Posted on 2003-11-09
7
797 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
7 Comments
 
LVL 1

Expert Comment

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

Expert Comment

by:purpleblob
ID: 9714384
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
ID: 9716458
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
ID: 9716471
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

696 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