HtmlTable.RenderChildren(HtmlTextWriter) Methode

Definition

Rendert die untergeordneten Steuerelemente des HtmlTable-Steuerelements in das angegebene HtmlTextWriter-Objekt.

protected:
 override void RenderChildren(System::Web::UI::HtmlTextWriter ^ writer);
protected public:
 override void RenderChildren(System::Web::UI::HtmlTextWriter ^ writer);
protected override void RenderChildren (System.Web.UI.HtmlTextWriter writer);
protected internal override void RenderChildren (System.Web.UI.HtmlTextWriter writer);
override this.RenderChildren : System.Web.UI.HtmlTextWriter -> unit
Protected Overrides Sub RenderChildren (writer As HtmlTextWriter)
Protected Friend Overrides Sub RenderChildren (writer As HtmlTextWriter)

Parameter

writer
HtmlTextWriter

Der HtmlTextWriter, der den gerenderten Inhalt empfängt.

Beispiele

Im folgenden Codebeispiel wird veranschaulicht, wie sie die RenderChildren Methode in einem benutzerdefinierten Serversteuerelement außer Kraft setzen, sodass eine neue Tabellenzeile an das HtmlTable Steuerelement angefügt wird.

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %>
<%@ Page Language="C#" AutoEventWireup="True" %>
<!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>
        <title>Custom HtmlTable - RenderChildren Example</title>
    </head>
    <body>
        <form id="Form1" 
          method="post" 
          runat="server">
            <h3>Custom HtmlTable - RenderChildren Example</h3>
      
      <aspSample:CustomHtmlTableRenderChildren 
        id="HtmlTable1" 
        name="HtmlTable1" 
        runat="server" 
        border="1"
        cellSpacing="0" 
        cellPadding="5">
        <tr>
          <td>1,1</td>
          <td>1,2</td>
          <td>1,3</td>
        </tr>
        <tr>
          <td>2,1</td>
          <td>2,2</td>
          <td>2,3</td>
        </tr>
        <tr>
          <td>3,1</td>
          <td>3,2</td>
          <td>3,3</td>
        </tr>
      </aspSample:CustomHtmlTableRenderChildren>

        </form>
    </body>
</html>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!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>
        <title>Custom HtmlTable - RenderChildren Example</title>
    </head>
    <body>
        <form id="Form1" 
          method="post" 
          runat="server">
            <h3>Custom HtmlTable - RenderChildren Example</h3>
      
      <aspSample:CustomHtmlTableRenderChildren 
        id="HtmlTable1" 
        name="HtmlTable1" 
        runat="server" 
        border="1"
        cellSpacing="0" 
        cellPadding="5">
        <tr>
          <td>1,1</td>
          <td>1,2</td>
          <td>1,3</td>
        </tr>
        <tr>
          <td>2,1</td>
          <td>2,2</td>
          <td>2,3</td>
        </tr>
        <tr>
          <td>3,1</td>
          <td>3,2</td>
          <td>3,3</td>
        </tr>
      </aspSample:CustomHtmlTableRenderChildren>

        </form>
    </body>
</html>
using System.Web;
using System.Security.Permissions;

namespace Samples.AspNet.CS.Controls
{
    [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
    public sealed class CustomHtmlTableRenderChildren : System.Web.UI.HtmlControls.HtmlTable
    {
        protected override void RenderChildren(System.Web.UI.HtmlTextWriter writer)
        {
            // Call the base class's RenderChildren method.
            base.RenderChildren(writer);
            
            // Write out a new table row.
            writer.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Tr);
            writer.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Td);
            writer.Write("4,1");
            writer.RenderEndTag();
            writer.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Td);
            writer.Write("4,2");
            writer.RenderEndTag();
            writer.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Td);
            writer.Write("4,3");
            writer.RenderEndTag();
            writer.RenderEndTag();
        }
    }
}
Imports System.Web
Imports System.Security.Permissions

Namespace Samples.AspNet.VB.Controls
    <AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
    Public NotInheritable Class CustomHtmlTableRenderChildren
        Inherits System.Web.UI.HtmlControls.HtmlTable

        Protected Overrides Sub RenderChildren(ByVal writer As System.Web.UI.HtmlTextWriter)

            ' Call the base class's RenderChildren method.
            MyBase.RenderChildren(writer)

            ' Write out a new table row.
            writer.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Tr)
            writer.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Td)
            writer.Write("4,1")
            writer.RenderEndTag()
            writer.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Td)
            writer.Write("4,2")
            writer.RenderEndTag()
            writer.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Td)
            writer.Write("4,3")
            writer.RenderEndTag()
            writer.RenderEndTag()
        End Sub
    End Class
End Namespace

Hinweise

Die RenderChildren Methode stellt vor und nach dem Aufrufen der Methode der Basisklasse Control.RenderChildren zusätzliche Formatierungen bereit. Durch die zusätzliche Formatierung wird der gerenderte HTML-Code des HtmlTable Steuerelements einfacher lesbar, indem eine Zeilenrückgabe eingefügt und eingezogen wird, bevor die untergeordneten Steuerelemente des HtmlTable Steuerelements gerendert werden.

Die RenderChildren Methode wird hauptsächlich von Steuerelemententwicklern verwendet, die die Funktionalität des HtmlTable Steuerelements erweitern.

Gilt für

Siehe auch