O'Reilly logo

ASP.NET in a Nutshell by Matthew MacDonald, G. Andrew Duthie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

HtmlTextWriter

Synopsis

The ASP.NET framework uses this class when writing the client-side HTML for a Web Forms page. It contains a wealth of methods for rendering the appropriate content, and derives from the more generic System.IO.TextWriter. Typically, you will not use this class directly in your code, unless you are a control developer.

When deriving custom controls from Control or System.Web.UI.WebControls.WebControl, you can override the Render() or RenderContents() method and create the control’s output by using the supplied HtmlTextWriter. Commonly used methods include Write(), which can output text or HTML tags, AddStyleAttribute(), which specifies a CSS style attribute for the next tag, and RenderBeginTag() and RenderEndTag(), which make it easy to insert open and closing HTML tags while keeping the code readable. The HtmlTextWriter also performs automatic indentation of the HTML output.

Public Class HtmlTextWriter : Inherits System.IO.TextWriter
' Public Constructors
   Public Sub New(ByVal writer As System.IO.TextWriter) 
   Public Sub New(ByVal writer As System.IO.TextWriter, 
        ByVal tabString As String) 
' Public Shared Fields
   public const DefaultTabString As String
        //  = 
   public const DoubleQuoteChar As Char   
        //  =&H000000022
   public const EndTagLeftChars As String 
        //  =</
   public const EqualsChar As Char        
        //  =&H00000003D
   public const EqualsDoubleQuoteString As String                // ==”
   public const SelfClosingChars As String
        //  = /
   public const SelfClosingTagEnd As String                      // = /> public ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required