Change button backcolor in C# ASP.NET

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..
 
A

avnrao

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..
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top