System.Web.UI.WebControls.Label Class

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

See Also: Label Members


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


In this topic:


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.


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.


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


    BackColor="color name|#dddddd"
    BorderColor="color name|#dddddd"


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