Yoshitha wrote:
private void btn_click(object sender, EventArgs e)
{
label1.Text= sender.Name;
}
Can any one tell me how to do this in c#.net?
Thanx in advance
Jyothi
Jyothi,
You need to typecast the sender variable to an object which has a name
property. Try something like this:
if (sender is Button)
{
label1.Text = ((Button)sender).Name;
}
I think a Control object has a name too, in which case you could make it
a little more general:
if (sender is Control)
{
label1.Text = ((Control)sender).Name;
}
Hope this helps.
Dan Manges