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 panel to your page.

  2. Set properties for the control in the Tag Properties panel.

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 Cc295530.xtlink_newWindow(en-us,Expression.40).png in the MSDN library.

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

Text display options

There are several choices to display text in a page:

  • HTML   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.

  • 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.

  • 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.

Labels as Control Captions

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 Cc295530.xtlink_newWindow(en-us,Expression.40).png in the MSDN library.

See also



Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.

Community Additions