TableCell.RenderContents Method (HtmlTextWriter)


This API supports the product infrastructure and is not intended to be used directly from your code.

Renders the TableCell contents to the specified HtmlTextWriter object.

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

protected internal override void RenderContents(
	HtmlTextWriter writer


Type: System.Web.UI.HtmlTextWriter

The output stream that renders HTML content to the client.

If the TableCell control has child controls or is overridden in a derived class the base class's RenderContents method is called; otherwise, the value of the Text property is written to the HtmlTextWriter object.

The RenderContents method is used primarily by control developers extending the functionality of the TableCell control.

The following code example demonstrates how to override the RenderContents method in a custom TableCell control so that it custom text is inserted in the cell's contents.

<%@ Page Language="C#" %>
<%@ Register TagPrefix="aspSample" 
    Assembly="Samples.AspNet.CS" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="" >
<head id="Head2" runat="server">
    <title>Custom TableCell - RenderContents - C# Example</title>
    <form id="form1" runat="server">

    <h3>Custom TableCell - RenderContents - C# Example</h3>

    <asp:Table id="Table1" runat="server" CellPadding="3" CellSpacing="2">
        <aspSample:CustomTableCellRenderContents Text="(0,0)" />
        <aspSample:CustomTableCellRenderContents Text="(0,1)" />
        <aspSample:CustomTableCellRenderContents Text="(0,2)" />
        <aspSample:CustomTableCellRenderContents Text="(1,0)" />
        <aspSample:CustomTableCellRenderContents Text="(1,1)" />
        <aspSample:CustomTableCellRenderContents Text="(1,2)" />

using System.Web;
using System.Security.Permissions;

namespace Samples.AspNet.CS.Controls
  [AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)]
  public sealed class CustomTableCellRenderContents : System.Web.UI.WebControls.TableCell
    protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)
      // Insert text into each TableCell.
      writer.Write("TableCell: ");

      // Call the base RenderContents method.

.NET Framework
Available since 1.1
Return to top