Button is disabled but looks active

So, I have a button that is currently disabled, and in IE it came out in gray, but in Firefox, Chrome and Safari it is disabled, but still looks active.

Button Code

<tr valign="middle"> <td colspan="2" style="width: 100%"> <asp:Button ID="DownloadButton" runat="server" Text="Download" Width="85px" CssClass="ESTableHeaderL" OnClick="DownloadButton_Click" /> </td> </tr> 

And my code is for

 protected void DownloadButton_Click(object sender, EventArgs e) { if (ddBusinessMonth.Items.Count == 0) { DownloadButton.Enabled = false; ShowClientMessageBox("No Data found for downloading"); } .... } 

Is there anything I can do to make it look the same as in IE?

thanks

+8
html css cross-browser
source share
4 answers

: disabled selector can be used with CSS3

 input[type="button"]:disabled { background:#dddddd; } 

Browser Compatibility:

  IE8+ FF1.5+ SA3.1+ OP9.2+ CH2+ 

For ASP.NET:

Add the CssClass attribute to your server button and assign it to the class containing the above CSS.

+8
source share

you can programmatically assign a css class if you disable it

 if (ddBusinessMonth.Items.Count == 0) { DownloadButton.Enabled = false; DownloadButton.CssClass = "disabledbutton"; ShowClientMessageBox("No Data found for downloading"); } 

CSS

 .disabledbutton{ background-color:#ddd; } 
+1
source share

Framerwork 4 performs management differently. Add below we.config to your file, and the button is disabled as usual.

 <pages controlRenderingCompatibilityVersion="3.5"/> 
0
source share

A quick way without using a custom CSS class (nothing against style sheets) that can be completed in code. The following will set the background color of your download button to green (I think it is green, I colorblind: - |):

 DownloadButton.Attributes.Add("style", "background-color:#28C523"); 
0
source share

All Articles