HtmlTable.RenderEndTag(HtmlTextWriter) Method

Definition

Renders the HtmlTable control's end tag.

C#
protected override void RenderEndTag(System.Web.UI.HtmlTextWriter writer);

Parameters

writer
HtmlTextWriter

The HtmlTextWriter that receives the rendered content.

Examples

The following code example demonstrates how to override the RenderEndTag method so that it always writes an end tag and a new line in a custom HtmlTable server control.

ASP.NET (C#)
<%@ 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 - RenderEndTag Example</title>
  </head>
  <body>
    <form id="Form1" 
          method="post" 
          runat="server">
      <h3>Custom HtmlTable - RenderEndTag Example</h3>

      <aspSample:CustomHtmlTableRenderEndTag 
        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:CustomHtmlTableRenderEndTag>

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

namespace Samples.AspNet.CS.Controls
{
    [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
    public sealed class CustomHtmlTableRenderEndTag : System.Web.UI.HtmlControls.HtmlTable
    {
        protected override void RenderEndTag(System.Web.UI.HtmlTextWriter writer)
        {
            // Write out the current TagName.
            writer.WriteEndTag(this.TagName);
            
            // Write out a new line.
            writer.WriteLine();
        }
    }
}

Remarks

The RenderEndTag method provides additional formatting after calling the base class's HtmlContainerControl.RenderEndTag method. The additional formatting makes the rendered HTML of the HtmlTable control easier to read by inserting a line return after the closing <table> tag.

The RenderChildren method is used primarily by control developers extending the functionality of the HtmlTable control.

Applies to

Ürün Sürümler
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also