Beginning ASP.NET 2.0 With CSharp (2006) [eng]
.pdfE
CSS and HTML
Quick Reference
This appendix provides a quick reference to CSS and HTML. It’s not meant to be an exhaustive and complete list of all HTML controls, their properties and the CSS properties, but rather to give the most common uses.
Styling Pages and Controls
You can style controls, or change their look and feel, in two ways: with properties of the control or with Cascading Style Sheets (CSS). Ultimately, both achieve the same thing, making the control look the way you want it to, but in practice, they are very different. Both Visual Web Developer and Visual Studio 2005 use properties when setting the style for controls. For example, if you drop a GridView onto your page and AutoFormat it with the Autumn format, you get the following:
<asp:GridView ID=”GridView1” runat=”server” BackColor=”White” BorderColor=”#CC9966” BorderStyle=”None” BorderWidth=”1px” CellPadding=”4”> <FooterStyle BackColor=”#FFFFCC” ForeColor=”#330099” />
<RowStyle BackColor=”White” ForeColor=”#330099” /> <PagerStyle BackColor=”#FFFFCC” ForeColor=”#330099”
HorizontalAlign=”Center” />
<SelectedRowStyle BackColor=”#FFCC66” Font-Bold=”True” ForeColor=”#663399”
/>
<HeaderStyle BackColor=”#990000” Font-Bold=”True” ForeColor=”#FFFFCC” /> </asp:GridView>
Here the BackColor sets the background color, and BorderColor sets the color of the border. The same sort of thing applies to the style for parts of the control, such as the FooterStyle and
RowStyle.
Although the approach of including the individual style attributes works fine, there are some issues: