开发者

changing background color of a text box

开发者 https://www.devze.com 2023-01-20 09:56 出处:网络
i have a dropdown list and text box. i disabled both controls using code behind. now, at one sight we can understand the dropdown list is disabled , because the background color of drop down list is c

i have a dropdown list and text box. i disabled both controls using code behind. now, at one sight we can understand the dropdown list is disabled , because the background color of drop down list is changed automatically.

i want to make that same background color to the text box control too. But i dont know what color code is that. i am working in asp.net . Any开发者_Python百科 suggestions??


Try this

 <asp:TextBox ID="txtCDate" runat="server" CssClass="textbox"  BackColor="#efefef" />


Actually, the "disabled" color may vary depending on the browser ... AFAIK, Firefox would put in a grey background to a disabled input box, and you could customize this behaviour via css with a selector like

input[disabled='disabled'] {
  ... styles go here ...
}

The problem is probably IE-specific, and in that case, this CSS selector would not work... You would probably need to add a specific CSS class to the disabled element to have more control over its look.

You could check this article about this issue : Shawn asks the CSS Guy about styling disabled text inputs


Assuming the reason the text box colors are different is because they have been explicitly set at some point during form validation.

To avoid having to explicitly set the grey color, and instead let the browser set the color to the "disabled" color automatically you could remove the custom color attribute from the text box.

"you can set the BackColor property to Color.Empty"

. . From a Similar Question answered by dustyburwell

In other words, something like myValidatedTextBox.BackColor = Color.Empty

0

精彩评论

暂无评论...
验证码 换一张
取 消