I have three buttons each calling btn_Clicked
on their onClick
event. In code behind I want to get the ID of the button that caused postback. I know I can assign each button to call a different method but I would like to learn a bit of ASP.Net. Also tell me which method is more efficient? Calling different methods on different button clicks or calling the same method (if the functionality of each button is same).
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Carriage Return (ASCII chr 13) is missing from tex
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
Check whether the
sender
argument of your callback method is the same reference as the button your are interested in.Cast the sender object to the button and then you can get all the properties.
If the functionality is same then it's better to have a single event, since you don't have to replicate code. Remember the DRY principle.
Consider the following example: