[RESOLVED]Disabled button not grayed out


I have an input button on my asp.net application’s aspx page. Framework is 4.0. I am disabling this button through Javascipt using the below statement:


The button was getting disabled and grayed-out with Internet explorer 8. But now I am testing this in v11 and the button is disabled but its not grayed-out. I am not using any css property to gray-out this button.

Any ideas on what may be the cause and how to fix it?

You can try using the cssclass to make the disabled button looks like grayed out.

Please try with the below implemenation:

Add the below css to your page

    .disabled { 


Then add the below code just below where you disable your button

//Assign the css tto button
     document.getElementById("button1").className = 'disabled';

Ensure that you change the id of button as per your design.

Use something like below


As the others mentioned, you can explicitly create a CSS style to customize the appearance of the element as you expected (either by directly creating one that targets disabled buttons as Ruchira suggests or by creating a custom class and applying it to
the button).

One thing to note, if this is an element that you are planning on actually submitting within a form and you need to access it in the Request, disabled elements will not be submitted / posted. You’ll likely want to use the readonly attribute instead and style
the element to appear disabled.

Leave a Reply