javascript how to dynamically add asp button code example

Example: javascript how to dynamically add asp button

<head runat="server">
    <title></title>
    <script type="text/javascript">
        window.addEventListener('load', function () {
            var submitbtn = document.createElement("INPUT");
            submitbtn.setAttribute("id", "button2");
            submitbtn.type = "submit";
            submitbtn.value = "SUBMIT2";
            submitbtn.addEventListener("click", postbackfunction);
            document.getElementById('form1').appendChild(submitbtn);

        });

        function postbackfunction() {
            console.log("Heihei");
            __doPostBack("submit", "");
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <div>
            <asp:Button ID="button1" runat="server" OnClick="button1_Click" Text="SUBMIT1" />

            <asp:TextBox ID="text1" runat="server"></asp:TextBox>
        </div>
    </form>
</body>