HtmlTextWriter Constructor (TextWriter, String) (System.Web.UI)

Switch View :
ScriptFree
.NET Framework Class Library
HtmlTextWriter Constructor (TextWriter, String)

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)
Syntax

Visual Basic
Public Sub New ( _
	writer As TextWriter, _
	tabString As String _
)
C#
public HtmlTextWriter(
	TextWriter writer,
	string tabString
)
Visual C++
public:
HtmlTextWriter(
	TextWriter^ writer, 
	String^ tabString
)
F#
new : 
        writer:TextWriter * 
        tabString:string -> HtmlTextWriter

Parameters

writer
Type: System.IO.TextWriter
The TextWriter that renders the markup content.
tabString
Type: System.String
The string to use to render a line indentation.
Remarks

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

Examples

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.

Visual Basic

' A custom class that overrides the CreateHtmlTextWriter method.
' This page uses the StyledLabelHtmlWriter to render its content.  
<AspNetHostingPermission(SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermission(SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
Public Class MyPage
    Inherits Page

    Protected Overrides Function CreateHtmlTextWriter(ByVal writer As TextWriter) As HtmlTextWriter
        Return New HtmlStyledLabelWriter(writer)
    End Function 'CreateHtmlTextWriter
End Class 'MyPage


C#


// 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);
    }

}


Visual C++

// A custom class that overrides its CreateHtmlTextWriter method.
// This page uses the StyledLabelHtmlWriter class to render its content.
public ref class MyPage: public Page
{
protected:
   virtual HtmlTextWriter^ CreateHtmlTextWriter( TextWriter^ writer ) override
   {
      return gcnew HtmlStyledLabelWriter( writer );
   }
};


Version Information

.NET Framework

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

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
See Also

Reference