Change the color of a button with a disabled link
I have a link button in my grid view and it will be disabled when certain conditions are met. My question is that when the button is disabled, the color of the button will change to gray, and I will not be gray, possibly black. I tried using the following code to change the gray to others, but it doesn't work. Do you guys want to do this?
Have tried:
LinkButton.ForeColor = Drawing.Color.Black
or
LinkButton.CssClass = "BlackLnkBtn"
or
LinkBUtton.Attributes("class") = "BlackLnkBtn"
+2
source to share
6 answers
I developed a solution where instead of disabling the button, I simply set the OnClick attributes to false when under certain conditions and using CSS Style it will remove the underline of the text.
This is my code ...
<CSS>
<style type="text/css">
.BlackLnkBtn
{
color:black;
text-decoration:none;
cursor:default;
}
</style>
<Code Behind>
LinkButton1.Attributes.Add("class", "BlackLnkBtn")
LinkButton1.Attributes("onclick") = "return false;"
+1
source to share