In addition to providing server-enabled HTML controls, ASP.NET provides a list of controls that provide much more enhanced functionality to developer GUI-rich, Web-based applications. As discussed earlier, these controls have become the preferred way of developing Web applications instead of (and in addition to) using the basic HTML controls (see Table 8.2). Table 8.2. ASP.NET Web Server Controls
Applying Style to ControlsASP.NET controls can be styled. What that implies is that depending on the control, a number of attributes (such as colors and fonts) are available to style it (see Figure 8.3). This is very similar to the styling of Windows Forms “based controls; even the attribute names are very similar. This goes along with the philosophy of bringing the ASP.NET and Windows Forms programming models closer together. <%@ Page Language="C#" %> <body> <form runat="server"> <asp:Label id="message" ForeColor="Red" text="Hello" runat="server"/> </form> </body> </html> Figure 8.3. Hello World with style!
In addition to the preceding style attributes (ForeColor, for example), some controls also provide the capability to specify the style of individual elements of the control. For instance, the following is a code snippet that shows a calendar control with the selected date styled as green (see Figure 8.4). This can be applied in a flight reservation example that provides styles of dates in different colors and fonts, depending on what kind of fares are available. <%@ Page Language="C#" %> <body> <form runat="server"> <asp:Calendar id="fromDate" runat="server"> <SelectedDayStyle ForeColor="White" BackColor="Black"/> </asp:Calendar> </form> </body> </html> Figure 8.4. Styled calendar control.
|