Jul 31, 2007

ASP.NET AJAX Life Cycle

  1. Sys.Application.init(event handle need Sys.Application.add_init(MyInit);
  2. Sys.Application.load (event handler function pageLoad(sender, args){}
  3. Sys.Application.unload (event handler function pageUnLoad(sender, args){}
  4. Sys.Application.disposing( inherit from Component class)
  5. Sys.Application.propertyChanged( inherit from Component class)
  1. Sys.WebForms.PageRequestManager.initializeRequest
  2. Sys.WebForms.PageRequestManager.beginRequest
  3. Sys.WebForms.PageRequestManager.pageLoading
  4. Sys.WebForms.PageRequestManager.pageLoaded
  5. Sys.WebForms.PageRequestManager.endRequest

For detail see this

            Sys.Application.add_init(applicationInit);
            //Sys.Application.add_load(applicationLoad);
            Sys.Application.add_unload(applicationUnload);

            function applicationInit(sender, args)
            {
            alert("application init");
            }

            function pageLoad(sender, args) {
            //function applicationLoad(sender, args) {
            alert("application load");
            }

            function applicationUnload(sender, args)
            {
            alert("application unload");
            }

            Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(pageRequestInitRequestHandler);
            Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(pageRequestManagerBeginRequestHandler);
            Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(pageReqeustPageLoading);
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(pageRequestManagerEndRequestHandler);
            Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageRequestManagerLoadHandler);

            function pageRequestInitRequestHandler(sender, args)
            {
            alert("PageRequestManager initRequest");
            }

            function pageReqeustPageLoading(sender, args)
            {
            alert("PageRequestManager pageLoading");
            }

            function pageRequestManagerBeginRequestHandler(sender, args)
            {
            alert("PageRequestManager beginRequestr");
            }

            function pageRequestManagerLoadHandler(sender, args)
            {
            alert("PageRequestManager pageLoaded");
            }

            function pageRequestManagerEndRequestHandler(sender, args)
            {
            alert("PageRequestManager endRequest");
            }
            

For the initial load, the event sequence is PageRequestManager pageLoaded, application init, application load. For asynchronous call, is PageRequestManager initRequest, PageRequestManager beginRequest, PageRequestManager pageLoading, PageRequestManager pageLoaded, application load, PageRequestManager endRequest.