In this hour we looked at the two ASP.NET Web controls designed for displaying text output: the Literal Web control and the Label Web control. These two Web controls differ in the HTML markup they produce when being rendered.
When the Literal Web control is rendered, its Text property is returned as its HTML markup. No formatting is applied, and no extraneous HTML tags are added.
The Label Web control is useful for displaying formatted textfor example, if you want to display some text in a bold font or with a yellow background color. To accommodate this, the Label Web control has a number of display properties available, such as BackColor, ForeColor, Font, BorderColor, BorderStyle, and so on.
When a Label Web control is rendered, not only is the Text property displayed, but an additional HTML <span> element is emitted to provide the formatting specified by the various formatting property values.
Now that we've examined how to use the Literal and Label Web controls, we're ready to turn our attention to the Web controls that are designed to collect user input, such as the TextBox Web control, the DropDownList Web control, the RadioButton Web control, and others. Before we do, though, we need to examine how an ASP.NET web page collects data from a web visitor and returns that data to the web server. We'll tackle this subject in the next hour, "Web Form Basics."