Here is a really quick CSS item to apply styles to different types of textboxes in an ASP.Net application. A plain old vanilla asp:textbox control will show as an Input if you view the source of the page. To set the styles of all those controls from a css file you can add this to your css:
input[type=”text”]
{
font-size: 8pt;
font-family: Arial;
}
Then you do not need to add the CssClass property to the textboxes in the aspx file. The input section of the css will be applied automatically. This saves some time and you only need to change the styles in one place. However if you have a textbox with the TextMode property set they will not render as an Input but rather as a Textarea. So to set all those types of asp:textboxes in your css file just add the following to you css file:
textarea
{
font-size: 8pt;
font-family: Arial;
}
After that both “types” of textboxes should have the same font size and family.
NOTE: See the first comment. Using input[type=”text”] will work for compliant browsers to prevent the style from being applied to other input types like buttons, checkboxes, radio, etc.
Technorati Tags:
ASP.Net,
CSS