How to change back color on multiple buttons with extra button

Hoeivfribgifs

New Member
I have a lot of buttons on page. Every button has white color as background color, and when I click on button it changes color to yellow.\[code\] protected void Button1_Click(object sender, EventArgs e) { if(((Button)sender).BackColor != Color.Red) {((Button)sender).BackColor = Color.Yellow;} }\[/code\]With one extra button I want to change the backcolors that are yellow to red. How to do this?I know it can be done like this:\[code\] protected void Button7_Click(object sender, EventArgs e) { if (Button1.BackColor == Color.Yellow) { Button1.BackColor = Color.Red; } if (Button2.BackColor == Color.Yellow) { Button2.BackColor = Color.Red; } }\[/code\]but I need a quicker way, so I don't have to write for every button specially
 
Back
Top