System.Web.UI.WebControls.Label Class

Represents a label control, which displays text on a Web page.

See Also: Label Members

Syntax

[System.Web.UI.ControlValueProperty("Text", null)]
[System.Web.UI.ToolboxData("<{0}:Label runat="server" Text="Label"></{0}:Label>")]
[System.Web.UI.ParseChildren(false)]
[System.ComponentModel.Designer("System.Web.UI.Design.WebControls.LabelDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner")]
[System.ComponentModel.DefaultProperty("Text")]
[System.Web.UI.DataBindingHandler("System.Web.UI.Design.TextDataBindingHandler, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.Web.UI.ControlBuilder(typeof(System.Web.UI.WebControls.LabelControlBuilder))]
public class Label : WebControl, System.Web.UI.ITextControl

Remarks

In this topic:

Introduction

Use the System.Web.UI.WebControls.Label control to display text in a set location on the page. Unlike static text, you can customize the displayed text through the Label.Text property.

You can also use the System.Web.UI.WebControls.Literal and System.Web.UI.WebControls.PlaceHolder controls to display text on the Web Forms page. However, unlike the System.Web.UI.WebControls.Label control, these controls do not render any additional tags.

Note:

This control can be used to display user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview.

Accessibility

For information about how to configure this control so that it generates markup that conforms to accessibility standards, see Accessibility in Visual Studio 2010 and ASP.NET 4 and ASP.NET Controls and Accessibility.

Declarative Syntax

Example

<asp:Label
    AccessKey="string"
    AssociatedControlID="string"
    BackColor="color name|#dddddd"
    BorderColor="color name|#dddddd"
    BorderStyle="

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0