Export (0) Print
Expand All

HtmlTextWriter.HtmlTextWriter(TextWriter, String) Constructor

Initializes a new instance of the HtmlTextWriter class with a specified tab string character.

Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)

public HtmlTextWriter (
	TextWriter writer,
	string tabString
)
public HtmlTextWriter (
	TextWriter writer, 
	String tabString
)
public function HtmlTextWriter (
	writer : TextWriter, 
	tabString : String
)
Not applicable.

Parameters

writer

The TextWriter that renders the markup content.

tabString

The string to use to render a line indentation.

The HtmlTextWriter overload of the HtmlTextWriter(TextWriter,String) constructor uses tabString when indentation of a line is necessary. It calls the System.IO.TextWriter base constructor to initialize the new instance.

The following code example demonstrates how to use the HtmlTextWriter(TextWriter) constructor to create a custom HtmlTextWriter object named StyledLabelHtmlWriter. When the MyPage custom class, which is derived from the Page class, is requested by a client browser, it uses the StyledLabelHtmlWriter class to render its content to the output stream.


// A custom class that overrides its CreateHtmlTextWriter method.
// This page uses the HtmlStyledLabelWriter class to render its content.
[AspNetHostingPermission(SecurityAction.Demand,
    Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand,
    Level = AspNetHostingPermissionLevel.Minimal)]
public class MyPage : Page
{
    protected override HtmlTextWriter CreateHtmlTextWriter(TextWriter writer)
    {
        return new HtmlStyledLabelWriter(writer);
    }

}

// A custom class that overrides its CreateHtmlTextWriter method.
// This page uses the HtmlStyledLabelWriter class to render its content.
public class MyPage extends Page
{
    protected HtmlTextWriter CreateHtmlTextWriter(TextWriter writer)
    {
        return new HtmlStyledLabelWriter(writer);
    } //CreateHtmlTextWriter
} //MyPage

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft