asp:TextBox Disabled style is not consistent in different Browsers
ASP.NET
When TextBox1.Enabled = false;
it has a gray background in FF3, b开发者_开发百科ut no change in IE8 or Chrome. So it's harder to tell if it's disabled or not. Is there any more general way to make the disable textbox rendered more consistent on a top-level? So I don't need to change this for every page or every website? Please advise, thanks.
You could set a CSS style to handle disabled text controls to render them consistently. For example, something like the following:
input[type="text"][disabled] {
background-color: #ECECEC;
border: solid 1px #7F9DB9;
color: #CCCCCC;
}
For IE7 support (and possibly even IE8), a !DOCTYPE
must be specified or CSS attribute selectors will not work. Unfortunately, if you require support for IE6 this will not work and you have to use a CSS class on any text input instead.
You can assign a CSS class to it using the CssClass
property and control it as much as you want.
More on the CssClass property here.
Sample CSS:
.DisabledTextBox {
background-color: #C0C0C0;
border: solid 1px #A0A0A0;
color: #A0A0A0;
}
Then use the CssClass like this:
<asp:TexbBox id="DisabledTextBox" CssClass="DisabledTextBox" value="Some Value" />
精彩评论