9

Why when I set enabled=false on a button does it not render correctly in Firefox? Instead of graying out the link it is still blue.

[UPDATE]

ASP.net already removes such tags on the link so the only thing that is needed is to grey out he link. In other words a CSS style change not a functionality change.

The following effectively resolved the disabled buttons not showing up as grayed out in firefox and google chrome. I put this into my style sheet and now all my link buttons render correctly.

a[disabled]{
color:Grey !important; text-decoration:none !important; }

Middletone
  • 4,076
  • 12
  • 51
  • 71

5 Answers5

12
a[disabled]
{
   color:Grey; text-decoration:none;
}

worked for me, Thank you...

Abdul Munim
  • 17,662
  • 7
  • 48
  • 59
2

When you disable a button it adds "aspNetDisabled" class to the button. so you can easily set the "aspNetDisabled" class with whatever you want.

 .aspNetDisabled {
        color: black;
        background-color: #e3e3e3;
        text-decoration: none;
    }
Veysel
  • 23
  • 3
2

From W3Scholl, "Enabled" Property isn't standard property of XHTML 4(It's Microsoft standard.). You should remove href property from hyperlink or using my following code

// cancel click event.
LinkButton1.Attributes["OnClick"] = "return false;";
// set css to display same disabled link in all browser
LinkButton1.CssClass = "LinkButton_Disabled";
Soul_Master
  • 7,561
  • 8
  • 59
  • 92
  • 2
    I think you are confusing the property of the server control with what's actually rendered... For Firefox, `Enabled="false"` renders as `disabled="disabled"`. – Alex Angas Nov 29 '12 at 03:01
1

In C#, I found that an extension is the most helpful to create a cross-browser solution.

public static class Extensions
{
    public static void Disable(this HtmlAnchor obj)
    {
        obj.Attributes.Remove("href");
        obj.Attributes.Add("disabled", "true");
        obj.Style.Add("color", "gray");
    }
}
Todd H.
  • 2,472
  • 1
  • 17
  • 9
  • 1
    To those who downvote... EXPLAIN WHY! Regardless of it being justified to you, explain to the originator and other readers why you downvoted. – tjmoore Dec 17 '12 at 12:24
0

The solution below is for buttons not link but it can be done for link as well.

var obj = document.getElementById('buttonId'');
getLabel = function(elem){
if (elem.id && elem.id=="label") {
elem.id = "disabledLabel";
}
};            
Dom.getElementsBy(getLabel ,'td', obj);

This will show button as disable or grayed out.

Nikhil D
  • 2,416
  • 3
  • 19
  • 41
vsingh
  • 5,439
  • 2
  • 46
  • 51