<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MyControl.aspx.cs" Inherits="WebApplication1.MyControl" %>

<!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>Test kontrolki!</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="SM1" runat="server" />

    <script type="text/javascript">
        MyControl = function(element) {
            MyControl.initializeBase(this, [element]);
        };
        MyControl.prototype = {
            initialize: function() {
                MyControl.callBaseMethod(this, "initialize");
            },
            dispose: function() {
                MyControl.callBaseMethod(this, "dispose");
            }
        };
        MyControl.registerClass("MyControl", Sys.UI.Control);
    </script>

    <div id="MyDiv">
    </div>

    <script type="text/javascript">
        var myControl = $create(MyControl, null, null, null, $get("MyDiv"));
        alert ("Identyfikator elementu związanego z kontrolką myControl: " + myControl.get_element().id);
        
        alert ("Identyfikator kontrolki związanej z elementem MyDiv: " + $get("MyDiv").control.get_id());
       
        // generuje błąd JavaScriptu, ponieważ z obiektem MyDiv jest już związana jakaś kontrolka.
        var myControl2 = $create(MyControl, null, null, null, $get("MyDiv")); 
    </script>

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