.NET TextBox BackColor issue
On a .NET page, I have a textbox. If I don't change the BackColor
property, it looks flat. Howev开发者_Python百科er, when using BackColor
, e.g.:
txt.BackColor = System.Drawing.Color.Yellow;
the look changes to some sort of "3D" which I don't really like. Is it possible to avoid this effect?
first:
edited:
It seems backcolor influences the borderstyle-property? which makes no sense to me, but I can simulate the look of a "normal" textbox like this
<asp:TextBox runat="server" ID="valueTxt" Enabled="false" BackColor="#E8E8E8" Width="50px" BorderStyle="NotSet" BorderWidth="1px" BorderColor="#B0B0B0"></asp:TextBox>
Welcome to the world of browsers. Browsers use the current OS and there own controls to render controls. So on a Mac using Safari, text boxes may look different to Firefox on Ubuntu & IE on Windows.
You can influence this by setting styles but you're still dependant on the browser. What would be better would be to create a css file with all the styles you want to apply to an input element defined, or create a css class so you can apply them independently. You only need reference the css file then to get the styling, rather than setting all those properties every time.
Simon
I had this same issue where the text box was being set to ".Enabled=false" and ".BackColor = Color.LightGrey". The textbox border was being changed to "3D".
Just setting the ".Enabled=false" sets the text box to grey by default. Changing it back to ".Enabled=true" set the text box back to white.
The border was not changed.
So don't change the .BackColor if you do not have to.
精彩评论