Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a linkbutton named "linkbutton1" on my webpage in asp.net(c#)
Now i want to change color of linkbutton1 when it gets disabled.
I want to do this using an event which will fire on disabled process of linkbutton
Same as there is an event of RowDatabound in gridview control, which fires when we call databind() method.
Same way when i make my linkbutton1 disabled,i.e enable=false, an event should fire which will change the color of linkbutton1,

How can i do this in C#
Posted

You can change the color of the link button, the moment you execute the statement linkbutton1.enable=false;.

The following code will do the trick:
LinkButton1.Enabled = false;
LinkButton1.ForeColor = System.Drawing.Color.Black;

Hope this answers your question
 
Share this answer
 
Thanx for ur reply
but i dont want to write that color change code in any click event.
I have got a situation where i want to fire an event when linkbutton gets disabled
 
Share this answer
 
Although you can update this in C# in the code-behind, the proper way would really be to use CSS and JavaScript on the client.

$(document).ready(function()
{
  $("input[type='button']:disabled").each(function()
   { 
     $(this).addClass(disableClass);
   });
}
);


This will execute after the document has loaded on the client but the same code can be applied to any client-side event to update the css for disabled buttons.
 
Share this answer
 
hey thanx mark for ur reply.
But do this code will fire each time when my linkbutton gets disabled.

Regards
Markand Bhatt
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900