Examining the Web Controls Designed for Displaying Text


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

  • The HTML markup that is rendered by the Web controls

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.




Sams Teach Yourself ASP. NET 2.0 in 24 Hours, Complete Starter Kit
Sams Teach Yourself ASP.NET 2.0 in 24 Hours, Complete Starter Kit
ISBN: 0672327384
EAN: 2147483647
Year: 2004
Pages: 233

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net