2 of 2 people found this helpful
If you are going to call the same function from multiple Button Click() event handlers, you should not bind that function to any control. So your target function TestButtonToggle_Click() should be a completely standalone function - currently it's signature looks like an event handler for a button control. Once you have it properly defined, you simply add a string parameter to your method signature. When you call this function from one of your button event handlers, you pass the button name as the parameter to the function.
Looking at your code however, you can probably simplify it even more and just call your ToggleRoomState() function directly from the button click event handlers and pass in the appropriate name value. There's no reason that I can see from the limited information available that you can't just directly call the ToggleRoomState() function from each button's event handler and pass in a hard-coded string value appropriate for that button.
Did John's answer get you on the right track? I would agree on both accounts with him; it sounds like you can directly call the ToggleRoomState function with a hard coded button name from each button click event, and if it's actually more complex than this example, you can implement a custom function that each of the button click events pass their button names to.
Or was your concern about keeping the button names in sync with the AF elements if they were to ever change, therefore not hard coding anything?