Overriding Page class constructor in ASP.NET code-behind file -- when is it called?

Posted by CSharp Noob on Stack Overflow See other posts from Stack Overflow or by CSharp Noob
Published on 2010-05-13T07:05:46Z Indexed on 2010/05/15 8:44 UTC
Read the original article Hit count: 242

Filed under:
|
|
|

If I override the System.Web.UI.Page constructor, as shown, when does DoSomething() get called in terms of the page lifecycle? I can't seem to find this documented anywhere.

namespace NameSpace1
{
    public partial class MyClass : System.Web.UI.Page
    {
        public MyClass()
        {
            DoSomething();
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}

For reference, here is the ASP.NET Page Lifecycle Overview:

http://msdn.microsoft.com/en-us/library/ms178472.aspx

Turns out the best answer was right in the MSDN article. I just had to look carefully at the diagram.

alt text

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET