다음을 통해 공유


Literal.Render(HtmlTextWriter) 메서드

정의

클라이언트에서 렌더링할 콘텐츠를 쓰는 지정된 HtmlTextWriter 개체에 서버 컨트롤 콘텐츠를 보냅니다.

protected:
 override void Render(System::Web::UI::HtmlTextWriter ^ output);
protected public:
 override void Render(System::Web::UI::HtmlTextWriter ^ writer);
protected override void Render (System.Web.UI.HtmlTextWriter output);
protected internal override void Render (System.Web.UI.HtmlTextWriter writer);
override this.Render : System.Web.UI.HtmlTextWriter -> unit
override this.Render : System.Web.UI.HtmlTextWriter -> unit
Protected Overrides Sub Render (output As HtmlTextWriter)
Protected Friend Overrides Sub Render (writer As HtmlTextWriter)

매개 변수

outputwriter
HtmlTextWriter

서버 컨트롤 콘텐츠를 받는 HtmlTextWriter 개체입니다.

예제

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

<%@ 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 LiteralControl - Render - C# Example</title>
       <script runat="server">
      void Button1_Click(Object sender, EventArgs e)
      {
         Literal1.Text = "Welcome to ASP.NET!";
      }
   </script>
    </head>
    <body>
        <form id="Form1" method="post" runat="server">
            <h3>Custom LiteralControl - Render - C# Example</h3>
            
            <aspSample:CustomLiteralRender id="Literal1" 
              runat="server" />

      <br /><br />

      <asp:Button id="Button1"
        Text="Change"
        OnClick="Button1_Click"
        runat="server"/>
        </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 LiteralControl - Render - VB.Net Example</title>
       <script runat="server">
      Sub Button1_Click(sender As Object, e As EventArgs)
      
         Literal1.Text = "Welcome to ASP.NET!"

      End Sub
   </script>
    </head>
    <body>
        <form id="Form1" method="post" runat="server">
            <h3>Custom LiteralControl - Render - VB.Net Example</h3>
            
            <aspSample:CustomLiteralRender id="Literal1" 
              runat="server" />

      <br /><br />

      <asp:Button id="Button1"
        Text="Change"
        OnClick="Button1_Click"
        runat="server"/>
        </form>
    </body>
</html>
using System.Web;
using System.Security.Permissions;

namespace Samples.AspNet.CS.Controls
{
  [AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)]
  public sealed class CustomLiteralRender : System.Web.UI.LiteralControl
  {
    protected override void Render(System.Web.UI.HtmlTextWriter writer)
    {
      // Write out some literal text.
      writer.Write("Literal Text: ");
      
      // Call the base Render method.
      base.Render(writer);
    }
  }
}
<AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class CustomLiteralRender
    Inherits System.Web.UI.WebControls.Literal

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

        ' Write out some literal text.
        writer.Write("Literal Text: ")

        ' Call the base Render method.
        MyBase.Render(writer)
    End Sub
End Class

적용 대상