Label control

The Label control provides you with a way to programmatically set text in an ASP.NET web page. You typically use the Label control when you want to change text in the page at run time, such as in response to a button click.

To add a Label control to a page

  1. Drag the Label control from the Toolbox task pane to your page.

  2. Set properties for the control in the Tag Properties task pane.

Common Label Properties




Specifies the text displayed in the label. In the user's browser, this is rendered as HTML.


Specifies the ID of the control for which you want the Label control to be the caption.

For a full description of all Label control properties, see Label Properties in the MSDN library.

The Label control provides one of several ways to display text in an ASP.NET web page.

Text display options


If you want to display static text, you can present it using HTML; you do not need a Label control. Use a Label control only if you need to change the contents or other characteristics of the text in server code.

The Label control

You can set the text of the Label control at design time or at run time in a program. You can also bind the Label control's Text property to a data source to display database information on a page.

The Literal control

Like the Label control, the Literal control allows you to programmatically set text to be displayed in the page. However, the Literal control does not support style properties.

You can use the Label control to act as an active caption in front of a TextBox control or other control. Users can then press an access key to move to the control for which the Label control is the caption. For details, see How to: Use Label Web Server Controls as Captions in the MSDN library.

Community Additions