Simply use the same handler for the different button Click events.
<asp:Button id='Button1' runat='server' Text='Button'></asp:Button>
<asp:Button id='Button2' style='Z-INDEX: 103; LEFT: 8px; POSITION: absolute; TOP: 80px' runat='server'
Text='Button'></asp:Button>
VB.NET
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click
Response.Write('hi you clicked ' + CType(sender, Button).ID)
End Sub
C#
// In InitializeComponent
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Button2.Click += new System.EventHandler(this.Button1_Click);
private void Button1_Click(object sender, System.EventArgs e)
{
Response.Write('hi you clicked ' + ((Button)sender).ID );
}
Share with