asp.net - 将代码隐藏中的按钮变灰在 IE 中不起作用

标签 asp.net css internet-explorer code-behind

我在一个页面上有两个下拉列表。行为如下:

  1. 选择列表 1 中的内容
  2. 列表 2 已启用
  3. 选择列表 2 中的内容
  4. 按钮已启用

我在下拉列表中启用了自动回发的情况下执行上述操作。要切换按钮,我使用以下代码:

if (ddlAvailablePrograms.SelectedValue != string.Empty)
{
     careerInfoLearnMoreSubmit.Enabled = true;
     careerInfoLearnMoreSubmit.Style.Remove("opacity");
     careerInfoLearnMoreSubmit.Style.Add("opacity", "1.0;");
}
else
{
     careerInfoLearnMoreSubmit.Enabled = false;
     careerInfoLearnMoreSubmit.Style.Remove("opacity");
     careerInfoLearnMoreSubmit.Style.Add("opacity", "0.5;");
}

这在 Firefox 中运行良好,但在 IE 中,只要我在第一个下拉列表中做出选择,按钮就会失去其灰色样式。

关于如何在 IE 中解决这个问题有什么建议吗?

谢谢,
b3n

最佳答案

opacity CSS 样式在 Internet Explorer 中存在已知问题。

尝试将其添加到您的 CSS 样式表中,而不是添加内联样式,而是添加一个类:

.opaque {
    -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; 
    filter: alpha(opacity=50);                  
}

顺序必须与上面完全相同。

此处显示/使用此技术:http://www.quirksmode.org/css/opacity.html

此外,我听说使用 jQuery 来应用不透明度是理想的,因为 jQuery 可以处理所有跨浏览器问题。这是一个选择吗?

关于asp.net - 将代码隐藏中的按钮变灰在 IE 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3654842/

相关文章:

由 html5sortable 的 sortupdate 触发的 JavaScript 运行了两次

c# - 找不到默认端点...但它就在那里?

jquery - 使用 CSS 格式化响应式菜单 (jQuery)

html - .net:应用程序在服务器上的 IE8 中丢失样式

html - 选项文本颜色在 IE/Edge 中为白色

javascript - 在 Internet Explorer 中对 svg 使用 AppendChild 是错误的

ASP.NET MVC : When should I create custom View Engine

c# - Silverlight 4 自定义登录

css - Box-shadow 的第三个值显着降低了页面渲染

javascript - IE8 中的 jQuery .animate 问题