Representa um Controlarar de rótulo, que exibe texto em uma página da Web.
Namespace:
System.Web.UI.WebControlsAssembly:
System.Web (em System.Web. dll)
Visual Basic (Declaração)
<ControlValuePropertyAttribute("Text")> _
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public Class Label _
Inherits WebControl _
Implements ITextControl
[ControlValuePropertyAttribute("Text")]
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class Label : WebControl, ITextControl
[ControlValuePropertyAttribute(L"Text")]
[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction::InheritanceDemand, Level = AspNetHostingPermissionLevel::Minimal)]
public ref class Label : public WebControl,
ITextControl
public class Label extends WebControl implements ITextControl
Use the Label control to display text in a set location on the page.Unlike static text, you can customize the displayed text through the Text property.
You can also use the Literal and PlaceHolder controls to display text on the Web Forms page.No entanto, diferentemente do controle Label, esses controles não processam as marcas adicionais.
Observação de segurança: |
|---|
Este Controlarar pode ser usado para exibir a entrada do usuário, que é uma ameaça potencial à segurança.Por padrão, páginas Web ASP.NET validam se as entradas de usuário não incluem scripts ou elementos HTML.Para mais informações, acesse Visão Geral de Scripts Maliciosos. |
Acessibilidade
A marcação processada por padrão para este controle pode atendem aos padrões de acessibilidade, como as diretrizes Prioridade 1 Web conteúdo acessibilidade diretrizes 1.0 (WCAG) não.For details about accessibility support for this control, see Controles ASP.NET e acessibilidade.
The following example demonstrates how to create a Label control on a Web page.
Observação: |
|---|
Exemplo de código a seguir usa o modelo de arquivo único código e pode não funcionar corretamente se copiado diretamente em um arquivo code-behind.Este exemplo de código deve ser copiado em um arquivo de texto vazia que possui uma extensão.aspx.For more information on the ASP.NET Web page code model, see Modelo de código de página Web do ASP.NET. |
Observação de segurança: |
|---|
Este exemplo tem uma caixa de texto que aceita entrada do usuário, que é uma ameaça potencial de segurança.Por padrão, páginas Web ASP.NET validam se as entradas de usuário não incluem scripts ou elementos HTML.Para mais informações, acesse Visão Geral de Scripts Maliciosos. |
<%@ Page Language= AutoEventWireup= %>
<!DOCTYPE html PUBLIC
>
<html xmlns= >
<head>
<title>Label Example</title>
<script language= runat=>
Button_Click(Sender Object, e EventArgs)
Label1.Text = Server.HtmlEncode(Text1.Text)
</script>
</head>
<body>
<form id= runat=>
<h3>Label Example</h3>
<asp:Label id=
Text=
runat=/>
<p>
<asp:TextBox id=
Text=
Width=
runat= />
<asp:Button id=
Text=
OnClick=
runat=/>
</p>
</form>
</body>
</html>
<%@ Page Language= AutoEventWireup= %>
<!DOCTYPE html PUBLIC "-
"http:
<html xmlns="http:
<head>
<title>Label Example</title>
<script language= runat=>
Button_Click(Object Sender, EventArgs e)
{
Label1.Text = Server.HtmlEncode(Text1.Text);
}
</script>
</head>
<body>
<form id= runat=>
<h3>Label Example</h3>
<asp:Label id=
Text=
runat=/>
<p>
<asp:TextBox id=
Text=
Width=
runat= />
<asp:Button id=
Text=
OnClick=
runat=/>
</p>
</form>
</body>
</html>
System..::.Object
System.Web.UI..::.Control
System.Web.UI.WebControls..::.WebControl
System.Web.UI.WebControls..::.Label
System.Web.UI.WebControls..::.BaseValidator
Quaisquer membros públicos estático (compartilhados na Visual Basic) desse tipo são Thread seguro. Não há garantia de que qualquer membro de instância seja isento de segmentos.
Referência
Outros recursos