<%@ Page Language="C#" AutoEventWireup="true" CodeFile="LoadEvent.aspx.cs" Inherits="LoadEvent" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
      <script type="text/javascript">
        
      MyReferencedComponent = function() { };
      MyReferencedComponent.registerClass("MyReferencedComponent", Sys.Component);
    
      MyOtherComponent = function() {
        this._referencedComponent = null;
      };
      
      MyOtherComponent.prototype = {
        get_referencedComponent: function() {
          return this._referencedComponent;
        },
        set_referencedComponent: function(value) {
          this._referencedComponent = value;
        }
      };
      MyOtherComponent.registerClass("MyOtherComponent", Sys.Component);
    
      Sys.Application.add_init(function() { $create(MyOtherComponent, {id:"MyOtherComponent"}, null, {referencedComponent: "MyReferencedComponent" }, null) });
      Sys.Application.add_init(function() { $create(MyReferencedComponent, {id:"MyReferencedComponent"}, null, null, null) });

      Sys.Application.add_load(
        function(sender, args) { 
          var createdComponents = args.get_components();
          if (createdComponents !== null) {
            for (var i=0; i<createdComponents.length; i++) {
              alert ("Komponent nr " + i+1 + ": " + createdComponents[i].get_id());
            }
          }
        }
      );

    </script>

    
    </form>
</body>
</html>
