
HtmlTextWriter | 651
UI Namespace
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Hierarchy
System.Object ➝ System.MarshalByRefObject ➝ System.IO.TextWriter(System.IDispos-
able)
➝ HtmlTextWriter ➝ Html32TextWriter
HtmlTextWriter
System.Web.UI (system.web.dll)
marshal by reference, disposable
class
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 auto-
matic indentation of the HTML output.
// Protected Instance Properties
protected Stack FontStack{get; }
// Public Instance Methods
public override void RenderBeginTag(HtmlTextWriterTag tagKey); // overrides ...