Freigeben über


Table.AddAttributesToRender-Methode

Fügt dem angegebenen HtmlTextWriter die darzustellenden HTML-Attribute und -Formatvorlagen hinzu.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

Syntax

'Declaration
Protected Overrides Sub AddAttributesToRender ( _
    writer As HtmlTextWriter _
)
'Usage
Dim writer As HtmlTextWriter

Me.AddAttributesToRender(writer)
protected override void AddAttributesToRender (
    HtmlTextWriter writer
)
protected:
virtual void AddAttributesToRender (
    HtmlTextWriter^ writer
) override
protected void AddAttributesToRender (
    HtmlTextWriter writer
)
protected override function AddAttributesToRender (
    writer : HtmlTextWriter
)

Parameter

  • writer
    Der Ausgabestream, der HTML-Inhalt für den Client rendert.

Hinweise

Diese Methode wird vorwiegend von Steuerelemententwicklern verwendet, um die entsprechenden Attribute und Formatvorlage in den HtmlTextWriter-Ausgabestream für ein Table-Steuerelement einzufügen. Diese Methode überschreibt WebControl.AddAttributesToRender.

Beispiel

Im folgenden Codebeispiel wird veranschaulicht, wie die AddAttributesToRender-Methode in einem benutzerdefinierten Serversteuerelement überschrieben wird, um der Table ein Attribut hinzuzufügen.

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %>
<%@ Page Language="VB" AutoEventWireup="True" %>
<HTML>
    <HEAD>
        <title>Custom Table - AddAttributesToRender - VB.NET Example</title>
    </HEAD>
    <body>
        <form id="Form1" method="post" runat="server">
            <h3>Custom Table - AddAttributesToRender - VB.NET Example</h3>

            <aspSample:CustomTableAddAttributesToRender id="Table1" runat="server" 
             GridLines="Both" CellPadding="4">
                <asp:TableRow>
                    <asp:TableCell>Row 0, Col 0</asp:TableCell>
                    <asp:TableCell>Row 0, Col 1</asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell>Row 1, Col 0</asp:TableCell>
                    <asp:TableCell>Row 1, Col 1</asp:TableCell>
                </asp:TableRow>
            </aspSample:CustomTableAddAttributesToRender>
        </form>
    </body>
</HTML>

...
Imports System.Web
Imports System.Security.Permissions

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

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

            ' Add a client-side onclick event to the button.
            writer.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Onclick, "alert('Hello World');")

            ' Call the base's AddAttributesToRender method.
            MyBase.AddAttributesToRender(writer)
        End Sub
    End Class
End Namespace
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %>
<%@ Page Language="C#" AutoEventWireup="True" %>
<HTML>
    <HEAD>
        <title>Custom Table - AddAttributesToRender - C# Example</title>
    </HEAD>
    <body>
        <form id="Form1" method="post" runat="server">
            <h3>Custom Table - AddAttributesToRender - C# Example</h3>

            <aspSample:CustomTableAddAttributesToRender 
              id="Table1" 
              runat="server" 
              GridLines="Both" 
              CellPadding="4">
        <asp:TableRow>
          <asp:TableCell>Row 0, Col 0</asp:TableCell>
          <asp:TableCell>Row 0, Col 1</asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
          <asp:TableCell>Row 1, Col 0</asp:TableCell>
          <asp:TableCell>Row 1, Col 1</asp:TableCell>
        </asp:TableRow>
      </aspSample:CustomTableAddAttributesToRender>
      
        </form>
    </body>
</HTML>

...
using System.Web;
using System.Security.Permissions;

namespace Samples.AspNet.CS.Controls
{
  [AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)]
  public sealed class CustomTableAddAttributesToRender : System.Web.UI.WebControls.Table
  {
    protected override void AddAttributesToRender(System.Web.UI.HtmlTextWriter writer)
    {
      // Add a client-side onclick event to the button.
      writer.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Onclick, "alert('Hello World');");

      // Call the base's AddAttributesToRender method.
      base.AddAttributesToRender(writer);
    }
  }
}
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL.Controls" Assembly="Samples.AspNet.JSL" %>
<%@ Page Language="VJ#" AutoEventWireup="True" %>
<HTML>
    <HEAD>
        <title>Custom Table - AddAttributesToRender - VJ# Example</title>
    </HEAD>
    <body>
        <form id="Form1" method="post" runat="server">
            <h3>Custom Table - AddAttributesToRender - VJ# Example</h3>

            <aspSample:CustomTableAddAttributesToRender 
              id="Table1" 
              runat="server" 
              GridLines="Both" 
              CellPadding="4">
        <asp:TableRow>
          <asp:TableCell>Row 0, Col 0</asp:TableCell>
          <asp:TableCell>Row 0, Col 1</asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
          <asp:TableCell>Row 1, Col 0</asp:TableCell>
          <asp:TableCell>Row 1, Col 1</asp:TableCell>
        </asp:TableRow>
      </aspSample:CustomTableAddAttributesToRender>
      
        </form>
    </body>
</HTML>

...
package Samples.AspNet.JSL.Controls; 

public class CustomTableAddAttributesToRender
    extends System.Web.UI.WebControls.Table
{
    protected void AddAttributesToRender(System.Web.UI.HtmlTextWriter writer)
    {
        // Add a client-side onclick event to the button.
        writer.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Onclick, 
            "alert('Hello World');");
        // Call the base's AddAttributesToRender method.
        super.AddAttributesToRender(writer);
    } //AddAttributesToRender
} //CustomTableAddAttributesToRender

Plattformen

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 unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

Table-Klasse
Table-Member
System.Web.UI.WebControls-Namespace

Weitere Ressourcen

Table-, TableRow- und TableCell-Webserver-Steuerelemente