This documentation is archived and is not being maintained.

Literal.Render Method

This member overrides Control.Render(HtmlTextWriter), and more complete documentation might be available in that topic.

Sends server control content to a provided HtmlTextWriter object, which writes the content to be rendered on the client.

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

protected internal override void Render(
	HtmlTextWriter writer


Type: System.Web.UI.HtmlTextWriter

The HtmlTextWriter object that receives the server control content.

The following code example demonstrates how to override the Render method in a custom server control so that specific text is always displayed before the 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"
<html xmlns="" >
        <title>Custom LiteralControl - Render - C# Example</title>
       <script runat="server">
      void Button1_Click(Object sender, EventArgs e)
         Literal1.Text = "Welcome to ASP.NET!";
        <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"


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.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0