Change button backcolor in C# ASP.NET

  • Thread starter Thread starter Grey
  • Start date Start date
G

Grey

how to change the button backcolor with C# in coding. I want to change back color of the button when I click it.


Million Thanks..
 
is it Server control or HTML control?
for server control :

Button2.BackColor = Color.Red;

for html control : you can do it on the script.. button.style.backgroundColor = "red";

Av.
how to change the button backcolor with C# in coding. I want to change back color of the button when I click it.


Million Thanks..
 
You could do this in client side script wit

[c#
btn.attributes["onclick"] = "this.style.backgroundColor='red';"

or if you were posting back to the server anyway, in the event handler for the button clic

[c#
btn.BackColor = Color.red

Ada
 
Back
Top