Two ASP.NET Web controls are designed for displaying text: the Literal Web control and the Label Web control. These two controls differ in the HTML markup that is rendered by each control when the ASP.NET web page is executed. Recall from our discussions in Hour 4 that when an ASP.NET web page is visited through a browser, the ASP.NET engine executes the page, producing HTML markup that is then sent back to the web server. This HTML markup is then sent from the web server back to the user's browser. The HTML markup produced by an ASP.NET web page can come from
The static HTML markup in the HTML portion is passed on to the browser exactly as it's typed in. However, the HTML markup produced by Web controls depends on the various property values of each Web control. The differences between the Literal and Label Web controls are in the HTML markup produced by each control. The Literal Web control HTML markup is simply the value of its Text property. The Label Web control, on the other hand, has a number of formatting properties, such as BackColor, ForeColor, Font, and so on, that specify how the Label's Text property should be displayed. In this hour we'll examine how to use each of these two Web controls, including how to add these Web controls to an ASP.NET web page's HTML portion and how to set their properties. |