lable
来源:互联网 发布:游戏公司的程序员累吗 编辑:程序博客网 时间:2024/04/30 20:46
表示在网页上显示文本的标签控件。
命名空间:System.Web.UI.WebControls 程序集:System.Web(在 system.web.dll 中)
语法
Visual Basic(声明)
<ControlValuePropertyAttribute("Text")> _Public Class Label Inherits WebControl Implements ITextControl
Visual Basic(用法)
Dim instance As Label
C#
[ControlValuePropertyAttribute("Text")] public class Label : WebControl, ITextControl
C++
[ControlValuePropertyAttribute(L"Text")] public ref class Label : public WebControl, ITextControl
J#
/** @attribute ControlValuePropertyAttribute("Text") */ public class Label extends WebControl implements ITextControl
JScript
ControlValuePropertyAttribute("Text") public class Label extends WebControl implements ITextControl
备注
使用 Label 控件在网页的设置位置上显示文本。不像静态文本,可以通过 Text 属性自定义显示文本。
也可以使用 Literal 和 PlaceHolder 控件在 Web 窗体页上显示文本。但与 Label 控件不同的是,这些控件不会呈现任何附加标记。
此控件可用来显示用户输入,而该输入可能包含恶意的客户端脚本。在您的应用程序中显示从客户端发送来的信息之前,先检查这些信息中是否有可执行脚本、SQL 语句或其他代码。可以在将输入文本显示在控件中之前使用验证控件验证用户输入。ASP.NET 提供了输入请求验证功能,可以阻止用户输入中的脚本和 HTML 代码。有关更多信息,请参见 保证标准控件的安全、如何:通过对字符串应用 HTML 编码在 Web 应用程序中防止脚本侵入 和 在 ASP.NET 网页中验证用户输入。
辅助功能
默认情况下为此控件呈现的标记可能不符合 Web 内容辅助功能准则 1.0 (WCAG) 中优先级为 1 的准则等辅助功能标准。有关此控件的辅助功能支持的详细信息,请参见 ASP.NET 控件和辅助功能。
示例
下面的示例说明如何在网页上创建 Label 控件。
下面的代码示例使用单文件代码模型,当它直接复制到代码隐藏文件时可能不能正常工作。此代码示例必须被复制到具有 .aspx 扩展名的空文本文件中。有关 Web 窗体代码模型的更多信息,请参见 ASP.NET 网页代码模型。
Visual Basic
复制代码
<%@ Page Language="VB" AutoEventWireup="True" %><html><head> <script language="VB" runat="server"> Sub Button_Click(Sender As Object, e As EventArgs) Label1.Text = Server.HtmlEncode(Text1.Text) End Sub </script></head><body> <form id="Form1" runat="server"> <h3>Label Example</h3> <asp:Label id="Label1" Text="Label Control" runat="server"/> <p> <asp:TextBox id="Text1" Text="Copy this text to the label" Width="200px" runat="server" /> <asp:Button id="Button1" Text="Copy" OnClick="Button_Click" runat="server"/> </p> </form></body></html>
C#
复制代码
<%@ Page Language="C#" AutoEventWireup="True" %><html><head> <script language="C#" runat="server"> void Button_Click(Object Sender, EventArgs e) { Label1.Text = Server.HtmlEncode(Text1.Text); } </script></head><body> <form id="Form1" runat="server"> <h3>Label Example</h3> <asp:Label id="Label1" Text="Label Control" runat="server"/> <p> <asp:TextBox id="Text1" Text="Copy this text to the label" Width="200px" runat="server" /> <asp:Button id="Button1" Text="Copy" OnClick="Button_Click" runat="server"/> </p> </form></body></html>
.NET Framework 安全性
- AspNetHostingPermission 用于在宿主环境中进行操作。要求值:LinkDemand;权限值:Minimal。
- AspNetHostingPermission 用于在宿主环境中进行操作。要求值:InheritanceDemand;权限值:Minimal
- lable
- lable
- lable
- lable
- winfrom lable
- 自适应lable
- lable设置
- lable属性
- Lable换行
- lable标签
- 根据lable内容设置lable的尺寸
- 关于<lable></lable>标签的理解
- Lable的新用法!
- lable 强制换行
- lable显示表单数据
- lable 中显示图片
- jfreechart Item Lable
- html lable的作用
- LoadRunner中自定义HTTP关联规则
- CompareValidator 构造函数
- 开发自己的Shell
- RegularExpressionValidator 事件
- GridView自定义分页
- lable
- 赞美大自然的生灵
- 项目管理规范-RUP管理实施(一)
- C#记事本
- button
- RowDataBound使用注意事项
- button
- 《QTP自动化测试实践》配套源代码
- 网络资源下载