a me questo codice funziona...mi crea il bottone con il testo "Nuovo pulsante".
Ma non funziona l'eventhandler associato.
codice:
<head runat="server"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btn_zero" runat="server" Text="Crea il secondo bottone !" OnClick="btn_zero_Click" />
</div>
</form>
</body>
</html>
codice:
protected void Page_Load(object sender, EventArgs e)
{
//
}
protected void btn_zero_Click(object sender, EventArgs e)
{
Button btn = new Button();
btn.Text = "Nuovo Pulsante";
btn.Click += new EventHandler(this.Button1_click);
btn.ID = "Button1";
System.Web.UI.HtmlControls.HtmlForm Form = (System.Web.UI.HtmlControls.HtmlForm)this.FindControl("form1");
Form.Controls.Add(btn);
}
void Button1_click(object sender, EventArgs e)
{
Response.Write("Hai cliccato il pulsante Button1");
}