Table.AddAttributesToRender(HtmlTextWriter) 메서드

정의

지정된 HtmlTextWriter에 렌더링되어야 하는 HTML 특성 및 스타일을 추가합니다.

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

매개 변수

writer
HtmlTextWriter

HTML 콘텐츠를 클라이언트에 렌더링하는 출력 스트림입니다.

예제

다음 코드 예제에서는 사용자 지정 서버 컨트롤에서 메서드를 재정의 AddAttributesToRender 하여 특성을 Table추가하는 방법을 보여 줍니다.

<%@ Page Language="C#" %>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %>

<!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 id="Head2" runat="server">
    <title>Custom Table - AddAttributesToRender - C# Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <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>
      
    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %>

<!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 id="Head2" runat="server">
    <title>Custom Table - AddAttributesToRender - VB Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <h3>Custom Table - AddAttributesToRender - VB 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>
      
    </div>
    </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);
    }
  }
}
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

설명

이 메서드는 컨트롤 개발자가 컨트롤의 출력 스트림 Table 에 적절한 특성 및 스타일을 삽입하는 HtmlTextWriter 데 주로 사용됩니다. 이 메서드는 WebControl.AddAttributesToRender를 재정의합니다.

적용 대상

추가 정보