共用方式為


HtmlTable.RenderEndTag(HtmlTextWriter) 方法

定義

轉譯 HtmlTable 控制項的結束標記。

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

參數

writer
HtmlTextWriter

HtmlTextWriter 接收轉譯的內容。

範例

下列程式碼範例示範如何覆寫 RenderEndTag 方法,使其一律會在自訂 HtmlTable 伺服器控制項中寫入結束標記和新行。

<%@ 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>
<%@ 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 - 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>
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();
        }
    }
}
Imports System.Web
Imports System.Security.Permissions

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

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

            ' Write out the current TagName.
            writer.WriteEndTag(Me.TagName)

            ' Write out a new line.
            writer.WriteLine()
        End Sub
    End Class
End Namespace

備註

方法 RenderEndTag 會在呼叫基類 HtmlContainerControl.RenderEndTag 的 方法之後提供額外的格式。 其他格式設定可讓控制項的 HtmlTable 轉譯 HTML 更容易閱讀,方法是在結尾 <table> 標記之後插入一行傳回。

方法 RenderChildren 主要是由控制項開發人員使用,以擴充控制項的功能 HtmlTable

適用於

另請參閱