I am having an ASP.WebSite in which I have added some form controls dynamically on aspx.cs using
form1.Controls.Add( " Object of Control ");
Also a have already added a button on form in aspx file using
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Add" UseSubmitBehavior="false" />
now when I run the program it converts the Button1 into an HTML submit button as below
<input type="button" name="Button1" value="Add" onclick="javascript:__doPostBack('Button1','')" id="Button1" />
and the form tag becomes
<form name="form1" method="post" action="Add1.aspx" id="form1" enctype="multipart/form-data">
when I click the Button1 it submits the form instead of calling the function on Code Behind.
How am I able to call the method Button1_Click specified on OnClick event of Button1?
Please Help.