Main Site Documentation

One TapEvent


#1

How can i write one event for multiple buttons using the object sender

e.g.

if(sender is btn1)
   do something;
if(sender is btn2)
   do something

is it possible to use sender for this purpose. if so can i get an example


#2

:slight_smile: :slight_smile: :). i just answerd my own question.

i dit not think that it was so simple


#3

Hi
I´m a very experience .net programer. It´s no correct (best pratic) to use one method to receive all event, if you can, read about oriented object programming. Make like this:

protected void btn2_TapEvent(object sender)
{
txtMatricula.Text += “2”;
}

    protected void btn3_TapEvent(object sender)
    {
        txtMatricula.Text += "3";
    }

#4

I have to disagree with you. What part of OOD does this violate?

It is a lot easier to read code with a limited of interrupt handlers that act as dispatchers.