Solved

page_load and constructor

Posted on 2003-11-09
7
781 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
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

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…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

860 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