Search code examples
asp.netcsssystemcolors

aspNetDisabled class default system colors


Where can I find the aspNetDisabled class default properties system color values? A ddl/select control background property is not "grayed" out when ddl.Enabled=false. For aesthetic purposes I want it to look similar to other disabled controls.

I can change the background of a DDL in the css with:

Select.aspNetDisabled
{
    background-color:ScrollBar;
} 

Setting all background colors to the same value like this:

.aspNetDisabled
{
    background-color:ScrollBar;
}

[surprisingly but makes sense now] is not a solution. Radio buttons and checkboxes have more than its "input area" grayed since the background for them consists of more than an input area. A rb becomes a grayed out square with a grayed out circle. I have tried ever possible SYSTEM COLOR that is available in VS2010 style builder color picker and none of them match. I can view the source and get the color there, but a hard coded value will not necessarily be identical on different machines. I like the default functionality of the aspNetDisabled class and only need to override the background for ddl's.


Solution

  • The aspNetDisabled deafult grayed out system color is "ButtonFace [in .css and buttonface from source]! I wrote a Javascript function to get the background color of a disabled TextBox. I tried the same code yesterday, but failed because of browser specific Javascript functions.

    Chrome did not like the property string I was passing to currentStyle[] - received an undefined property error:

    var txtBx = $get('<%=txtBx.ClientID %>');
    var prop = "background-color";  //also tried backColor and many other variations
    
    strValue = txtBx.currentStyle[prop];
    alert("strValue" + strValue);
    

    The getComputedStyle method worked, but of course that is not what I wanted. I ran the same Javascript using ie and was able to get the currentStyle[prop] value.

    aspNetDisabled is simply a variable for a class/.css. It would be nice to be able to see its values. I searched the Framework and the "net" yesterday for any related .css files/classes and for the string "aspNetDisabled". The only matches I encountered were aspNetDisabled in WebControls.cs and a WebAdminStyle.css under the 4.0 dir. I also tried to use the debugger, but could not find the style properties for "txtBX" as I expanded each layer.

    I guess writing Javascript a function to loop through all properties for each type of "disabled" control would accomplish that. There is probably a way to write a .net class to find all properties and their values of a .css class too.

    It is unclear to me why the background color of a DDL does not get modified when disabled...

    I hope this helps someone!