问题
I have two drop down lists on a page. The behavior is as follows:
- select something in list 1
- list 2 is enabled
- select something in list 2
- button is enabled
I am doing the above with autopostback enabled on the drop down lists. To toggle the button I use the code below:
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;");
}
This works fine in Firefox but in IE as soon as I make a selection in the first drop down list the button looses its greyed out style.
Any suggestions how to fix this in IE?
Thanks,
b3n
回答1:
The opacity CSS style has known issues with Internet Explorer.
Try adding this to your CSS stylesheet, and instead of adding an inline style, add a class:
.opaque {
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
}
Order has to be exactly like above.
This technique is shown/used here: http://www.quirksmode.org/css/opacity.html
Also, i have heard using jQuery to apply the opacity is ideal, because jQuery handles all cross-browser issues. Is that an option?
来源:https://stackoverflow.com/questions/3654842/greying-out-a-button-from-code-behind-does-not-work-in-ie