다음을 통해 공유


HtmlTextArea.RenderAttributes(HtmlTextWriter) 메서드

정의

HtmlTextArea 컨트롤의 특성을 지정된 HtmlTextWriter 개체에 렌더링합니다.

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

매개 변수

writer
HtmlTextWriter

렌더링된 콘텐츠를 받는 HtmlTextWriter입니다.

예제

다음 코드 예제에서는 특정 제목 텍스트 컨트롤에 RenderAttributes 대 한 항상 표시 되도록 사용자 지정 서버 컨트롤에서 메서드를 재정의 HtmlTextArea 하는 방법을 보여 줍니다.

<%@ 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">
<script runat="server">
  
  void Page_Load(Object sender, EventArgs e)
  {
    HtmlTextArea1.Value = "Hello HTML Text Area World.";
  }
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head>
    <title>Custom HtmlTextArea RenderAttributes Example</title>
  </head>

  <body>
    <form id="Form1" 
          method="post" 
          runat="server">

      <h3>Custom HtmlTextArea - RenderAttributes - C# Example</h3>

      <aspSample:CustomHtmlTextAreaRenderAttributes 
        id="HtmlTextArea1" 
        name="HtmlTextArea1" 
        runat="server" 
        rows="4" 
        cols="50" />
        
    </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">
<script runat="server">

  Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    
    HtmlTextArea1.Value = "Hello HTML Text Area World."
    
  End Sub
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head>
    <title>Custom HtmlTextArea RenderAttributes Example</title>
  </head>

  <body>
    <form id="Form1" 
          method="post"
          runat="server">

      <h3>Custom HtmlTextArea RenderAttributes Example</h3>

      <aspSample:CustomHtmlTextAreaRenderAttributes 
        id="HtmlTextArea1" 
        name="HtmlTextArea1" 
        runat="server" 
        rows="4" 
        cols="50" />
        
    </form>
  </body>
</html>
using System.Web;
using System.Security.Permissions;

namespace Samples.AspNet.CS.Controls
{
    [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
    public sealed class CustomHtmlTextAreaRenderAttributes : System.Web.UI.HtmlControls.HtmlTextArea
    {
        protected override void RenderAttributes(System.Web.UI.HtmlTextWriter writer)
        {
            // Write out the Title attribute.
            writer.Write(" Title=\"Text from RenderAttributes.\"");
            
            // Call the base class's RenderAttributes method.
            base.RenderAttributes(writer);
        }
    }
}
Imports System.Web
Imports System.Security.Permissions

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

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

            ' Write out the Title attribute.
            writer.Write(" Title=""Text from RenderAttributes.""")

            ' Call the base class's RenderAttributes method.
            MyBase.RenderAttributes(writer)
        End Sub
    End Class
End Namespace

설명

메서드는 RenderAttributes 컨트롤의 name HtmlTextArea 특성을 직접 렌더링하여 속성과 동일한 값을 Control.UniqueID 갖도록 합니다. 특성을 렌더링한 후 메서드는 RenderAttributes 기본 클래스의 RenderAttributes 메서드를 호출합니다.

합니다 RenderAttributes 메서드는 주로 컨트롤 개발자가 기능을 확장 합니다 HtmlTextArea 제어 합니다.

적용 대상

추가 정보