TableCell.RenderContents メソッド
アセンブリ: System.Web (system.web.dll 内)


TableCell コントロールに子コントロールがある場合、またはコントロールが派生クラスでオーバーライドされる場合は、基本クラスの RenderContents メソッドが呼び出されます。それ以外の場合は、Text プロパティの値が HtmlTextWriter オブジェクトに書き込まれます。
RenderContents メソッドは、主に、コントロール開発者が TableCell コントロールの機能を拡張する際に使用します。

カスタム コントロール TableCell の RenderContents メソッドをオーバーライドして、カスタム テキストがセルの内容に挿入されるようにする方法のコード例を次に示します。
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %> <%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> <title>Custom TableCell - RenderContents - VB.NET Example</title> </head> <body> <form id="Form1" method="post" runat="server"> <h3>Custom TableCell - RenderContents - VB.NET 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> </form> </body> </html>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %> <%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> <title>Custom TableCell - RenderContents - C# Example</title> </head> <body> <form id="Form1" method="post" runat="server"> <h3>Custom TableCell - RenderContents - C# 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> </form> </body> </html>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL.Controls" Assembly="Samples.AspNet.JSL" %> <%@ Page Language="VJ#" AutoEventWireup="True" %> <html> <head> <title>Custom TableCell - RenderContents - VJ# Example</title> </head> <body> <form id="Form1" method="post" runat="server"> <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> </form> </body> </html>
Imports System.Web Imports System.Security.Permissions Namespace Samples.AspNet.VB.Controls <AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _ Public NotInheritable Class CustomTableCellRenderContents Inherits System.Web.UI.WebControls.TableCell Protected Overrides Sub RenderContents(ByVal writer As System.Web.UI.HtmlTextWriter) ' Insert text into each TableCell. writer.Write("TableCell: ") ' Call the base RenderContents method. MyBase.RenderContents(writer) End Sub End Class End Namespace
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. base.RenderContents(writer); } } }
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); } }

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- TableCell.RenderContents メソッドのページへのリンク