handle several buttons' click events code example
Example 1: can you have multiple onclick events
<input type="button" value="test" onclick="Hey(); Ho();" />
Example 2: handle several buttons' click events
private int counter=0;
private void CreateButton_Click(object sender, EventArgs e)
{
Button button = new Button();
button.Name = "Butt"+counter;
button.Text = "New";
button.Location = new Point(70,70);
button.Size = new Size(100, 100);
counter++;
button.Click += new EventHandler(NewButton_Click);
}
private void NewButton_Click(object sender, EventArgs e)
{
Button btn = (Button) sender;
for (int i = 0; i < counter; i++)
{
if (btn.Name == ("Butt" + i))
{
break;
}
}
}