TableCell.Text 属性


获取或设置单元格的文本内容。Gets or sets the text contents of the cell.

 virtual property System::String ^ Text { System::String ^ get(); void set(System::String ^ value); };
public virtual string Text { get; set; }
public virtual string Text { get; set; }
member this.Text : string with get, set
Public Overridable Property Text As String


单元格的文本内容。The text contents of the cell. 默认值是 EmptyThe default value is Empty.



下面的代码示例演示如何以编程方式创建 TableCell 控件的新实例。The following code example demonstrates how to create a new instance of a TableCell control programmatically. 具体而言,请注意 Text 属性如何用于设置 TableCell 控件的内容。In particular, note how the Text property is used for setting the contents of the TableCell control.

此代码示例是为 TableCell 类提供的更大示例的一部分。This code example is part of a larger example provided for the TableCell class.

// Create more rows for the table.
for (int rowNum = 2; rowNum < 10; rowNum++)
    TableRow tempRow = new TableRow();
    for (int cellNum = 0; cellNum < 3; cellNum++)
        TableCell tempCell = new TableCell();
        tempCell.Text = 
            String.Format("({0},{1})", rowNum, cellNum);
' Create more rows for the table.
Dim rowNum As Integer
For rowNum = 2 To 9
    Dim tempRow As New TableRow()
    Dim cellNum As Integer
    For cellNum = 0 To 2
        Dim tempCell As New TableCell()
        tempCell.Text = _
            String.Format("({0},{1})", rowNum, cellNum)


使用 Text 属性指定或确定单元格的文本内容。Use the Text property to specify or determine the text contents of the cell. 此属性通常用于以编程方式更新单元的内容。This property is commonly used to programmatically update the contents of a cell.


设置 Text 属性将清除 TableCell中包含的任何其他控件。Setting the Text property will clear any other controls contained in the TableCell.


Text 控件可用于显示用户输入,其中可能包括恶意的客户端脚本。The Text control can be used to display user input, which might include malicious client script. 在应用程序中显示可执行脚本、SQL 语句或其他代码之前,请检查从该客户端发送的任何信息。Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. ASP.NET 提供输入请求验证功能来阻止用户输入中的脚本和 HTML。ASP.NET provides an input request validation feature to block script and HTML in user input. 还提供验证服务器控件以评估用户输入。Validation server controls are also provided to assess user input. 有关详细信息,请参阅保护标准控件如何:通过将 HTML 编码应用到字符串,并在 ASP.NET 网页验证用户输入来防范 Web 应用程序中的脚本攻击。For more information, see Securing Standard Controls, How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings, and Validating User Input in ASP.NET Web Pages.

设置此属性后,可以使用设计器工具自动将此属性的值保存到资源文件中。The value of this property, when set, can be saved automatically to a resource file by using a designer tool. 有关详细信息,请参阅 LocalizableAttribute全球化和本地化For more information, see LocalizableAttribute and Globalization and Localization.