protected void Page_Load(object sender, EventArgs e)
{
Button testButton = new Button();
testButton.Text = "pleaseClick";
testButton.Click += new EventHandler(button_Click);
form1.Controls.Add(testButton);
}
code on click event
protected void button_Click (object sender, EventArgs e)
{
ClientScript.RegisterClientScriptBlock(GetType(), "alert", "alert('Hi its a demo');", true);
}