TableCell.RenderContents Method
.NET Framework 3.0
This method supports the .NET Framework 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.WebControlsAssembly: System.Web (in system.web.dll)
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="VJ#" %>
<%@ Register TagPrefix="aspSample"
Namespace="Samples.AspNet.JSL.Controls"
Assembly="Samples.AspNet.JSL" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head2" runat="server">
<title>Custom TableCell - RenderContents - VJ# Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3>Custom TableCell - RenderContents - VJ# Example</h3>
<asp:Table id="Table1" runat="server" CellPadding="3" CellSpacing="2">
<asp:TableRow>
<aspSample:CustomTableCellRenderContents Text="(0,0)" />
<aspSample:CustomTableCellRenderContents Text="(0,1)" />
<aspSample:CustomTableCellRenderContents Text="(0,2)" />
</asp:TableRow>
<asp:TableRow>
<aspSample:CustomTableCellRenderContents Text="(1,0)" />
<aspSample:CustomTableCellRenderContents Text="(1,1)" />
<aspSample:CustomTableCellRenderContents Text="(1,2)" />
</asp:TableRow>
</asp:Table>
</div>
</form>
</body>
</html>
package Samples.AspNet.JSL.Controls;
public class CustomTableCellRenderContents
extends System.Web.UI.WebControls.TableCell
{
protected void RenderContents(System.Web.UI.HtmlTextWriter writer)
{
// Insert text into each TableCell.
writer.Write("TableCell: ");
// Call the base RenderContents method.
super.RenderContents(writer);
}
}
Community Additions
ADD
Show: