Literal.Render Method
.NET Framework 4.5
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.
Assembly: System.Web (in System.Web.dll)
Parameters
- 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" "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> ... 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); } } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.