How to style textbox using CSS in ASP.NET
I want to add style in ASP.NET textbox control. I couldn't find textbox element in elements list. I can put style in all input control开发者_开发问答s using the below code in CSS.
input
{
backgroud-color:black;
}
But this changes the background color of all input controls like buttons, radiobox, etc.
I want to do it exclusively with textbox, I don't want to do it with CSS class.
It would be easier to put css class on those textboxes (input type="text")
<style>
.textbox { /*some style here */ }
</style>
<input type="text" class="textbox" /> or
<asp:TextBox id="someid" runat="server" CssClass="textbox" />
This will do it:
input[type=text]
Though it might not work in all browsers (e.g. IE). The only way to ensure that would be to add a class or put it inside a span element.
A 100% cross browser, that works in IE6, is to make use of asp.net themes and skins. Create a skin file in the app_themes directory and add the following line:
<asp:TextBox runat="server" CssClass="textbox" />
This will then apply the CSS class "textbox" to every textbox in your site, assuming you have corresponding CSS and theme references.
Not 100% sure if this is what you're looking for but you can put CssClass="myTextBoxStyle"
in the ASP.NET server-side tag and then define a class called .myTextBoxStyle
in your stylesheet. It will then only affect textboxes where you've added CssClass="myTextBoxStyle"
input[type=text]
but won't work in IE.
Use a class name instead and apply that class to your text elements.
精彩评论