?
Solved

page_load and constructor

Posted on 2003-11-09
7
Medium Priority
?
803 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 150 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

765 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