javascript how to dynamically add asp button

Solutions on MaxInterview for javascript how to dynamically add asp button by the best coders in the world

showing results for - "javascript how to dynamically add asp button"
Taina
30 Oct 2020
1<head runat="server">
2    <title></title>
3    <script type="text/javascript">
4        window.addEventListener('load', function () {
5            var submitbtn = document.createElement("INPUT");
6            submitbtn.setAttribute("id", "button2");
7            submitbtn.type = "submit";
8            submitbtn.value = "SUBMIT2";
9            submitbtn.addEventListener("click", postbackfunction);
10            document.getElementById('form1').appendChild(submitbtn);
11
12        });
13
14        function postbackfunction() {
15            console.log("Heihei");
16            __doPostBack("submit", "");
17        }
18    </script>
19</head>
20<body>
21    <form id="form1" runat="server">
22        <asp:ScriptManager ID="ScriptManager1" runat="server">
23        </asp:ScriptManager>
24        <div>
25            <asp:Button ID="button1" runat="server" OnClick="button1_Click" Text="SUBMIT1" />
26
27            <asp:TextBox ID="text1" runat="server"></asp:TextBox>
28        </div>
29    </form>
30</body>