- HTML Controls
- HTML Server Controls
- Web Server Controls
- User Input Validation
- Cascading Style Sheets
- Exam Prep Questions
- Need to Know More?
Cascading Style Sheets
A Cascading Style Sheet (CSS) contains style definitions that are applied to elements in an HTML document. The information inside a CSS defines how HTML elements are displayed and where they are positioned on a Web page. With CSS, you can store all the formatting information for a Web application in a single CSS file and then instruct all the Web forms to use that file for formatting settings. This offers the following advantages:
Uniform look and feel
Ease of maintenance
You can use the GUI-based CSS designer available in Visual Studio .NET to easily create the CSS files and attach them to your Web application. The Web form does not automatically read the information in CSS files, though; you need to link a CSS file with the ASPX page using the HTML <link> element.
CSS also enables you to define custom style classes. A custom style class is applied to a Web server control using the CssClass property and to an HTML server control using the Class property. For example, if you have the following definition in the CSS file associated with the ASPX page and you want to apply this style to a TextBox Web server control, you simply need to change the CssClass property of the TextBox Web server control to TextBoxStyle. Here's how you do so:
.TextBoxStyle { border-right: blue double; border-top: blue double; font-size: medium; border-left: blue double; color: white; border-bottom: blue double; background-color: #6699cc; }