Using the Label Web Control

The Label Web control differs from the Literal Web control in that it contains a number of formatting properties that, when set, specify how the Text property should be displayed in the user's Web browser.

We saw that to display the Text property of the Literal Web control in a bold font, the Text property needed to include the appropriate HTML markup, such as <b> tags. With the Label Web control, however, we can display the text “Hello, World!” in a bold font by setting the Label Web control's Text property to Hello, World! and setting the Font property's Bold subproperty to True.

Let's create a new ASP.NET Web page to demonstrate using a Label Web control. Start by creating an ASP.NET Web page named LabelControl.aspx ...

Get SAMS Teach Yourself ASP.NET in 24 Hours now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.