ChtmlTextWriter 생성자
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
ChtmlTextWriter 클래스의 새 인스턴스를 초기화합니다.
오버로드
| ChtmlTextWriter(TextWriter) |
ChtmlTextWriter 상수를 사용하여 줄을 들여쓰는 DefaultTabString 클래스의 새 인스턴스를 초기화합니다. |
| ChtmlTextWriter(TextWriter, String) |
지정한 줄 들여쓰기를 사용하는 ChtmlTextWriter 클래스의 새 인스턴스를 초기화합니다. |
ChtmlTextWriter(TextWriter)
ChtmlTextWriter 상수를 사용하여 줄을 들여쓰는 DefaultTabString 클래스의 새 인스턴스를 초기화합니다.
public:
ChtmlTextWriter(System::IO::TextWriter ^ writer);
public ChtmlTextWriter (System.IO.TextWriter writer);
new System.Web.UI.ChtmlTextWriter : System.IO.TextWriter -> System.Web.UI.ChtmlTextWriter
Public Sub New (writer As TextWriter)
매개 변수
- writer
- TextWriter
태그 내용을 렌더링하는 TextWriter입니다.
예제
다음 코드 예제에서는 라는 ChtmlCustomPageAdapter 클래스를 만들고 클래스의 CustomChtmlTextWriter instance 만들고 반환하는 하나의 메서드 CreateCustomChtmlTextWriter를 정의하는 방법을 보여 줍니다.
CustomChtmlTextWriter cHTML cHTML 태그를 사용 하는 브라우저를 사용 하 여 디바이스에 페이지 내용을 렌더링 합니다.
이 코드 예제는에 대해 제공 된 큰 예제의 일부는 ChtmlTextWriter 클래스입니다.
// Derive from the WebControlAdapter class,
// provide a CreateCustomChtmlTextWriter
// method to attach to the custom writer.
public class ChtmlCustomPageAdapter : WebControlAdapter
{
protected internal ChtmlTextWriter CreateCustomChtmlTextWriter(
TextWriter writer)
{
return new CustomChtmlTextWriter(writer);
}
}
' Derive from the WebControlAdapter class,
' provide a CreateCustomChtmlTextWriter
' method to attach the custom writer.
Public Class ChtmlCustomPageAdapter
Inherits WebControlAdapter
Protected Friend Function CreateCustomChtmlTextWriter( _
ByVal writer As TextWriter) As ChtmlTextWriter
Return New CustomChtmlTextWriter(writer)
End Function
End Class
설명
클래스에는 ChtmlTextWriter 클래스에서 HtmlTextWriter 직접 또는 간접적으로 파생되는 모든 클래스에 대한 표준인 두 개의 생성자가 있습니다.
ChtmlTextWriter 클래스의 TextWriter instance 매개 변수로 사용하는 생성자는 두 번째 생성자를 호출하고 두 개의 매개 변수 값을 전달합니다.
XHTML 텍스트 작성기에서 DefaultTabString 사용하는 탭 간격을 정의하는 필드에 지정된 문자열 값입니다.
적용 대상
ChtmlTextWriter(TextWriter, String)
지정한 줄 들여쓰기를 사용하는 ChtmlTextWriter 클래스의 새 인스턴스를 초기화합니다.
public:
ChtmlTextWriter(System::IO::TextWriter ^ writer, System::String ^ tabString);
public ChtmlTextWriter (System.IO.TextWriter writer, string tabString);
new System.Web.UI.ChtmlTextWriter : System.IO.TextWriter * string -> System.Web.UI.ChtmlTextWriter
Public Sub New (writer As TextWriter, tabString As String)
매개 변수
- writer
- TextWriter
태그 내용을 렌더링하는 TextWriter입니다.
예제
다음 코드 예제에서는 클래스에서 파생 된 라는 CustomChtmlTextWriter 사용자 지정 클래스를 만드는 방법을 보여 줍니다 ChtmlTextWriter . 클래스에서 HtmlTextWriter 직접 또는 간접적으로 파생되는 모든 클래스와 동일한 패턴을 사용하여 사용자 지정 클래스의 instance 만드는 데 사용할 수 있는 두 개의 생성자를 만듭니다.
// Create a class that derives from the
// ChtmlTextWriter class.
using System;
using System.IO;
using System.Web.UI;
using System.Web.UI.WebControls.Adapters;
namespace AspNet.Samples.CS
{
public class CustomChtmlTextWriter : ChtmlTextWriter
{
// Create two constructors for the new
// text writer.
public CustomChtmlTextWriter(TextWriter writer) : base(writer, DefaultTabString)
{
}
public CustomChtmlTextWriter(TextWriter writer, String tabString)
: base(writer, tabString)
{
}
// Override the OnAttributeRender method to
// not render the bgcolor attribute, which is
// not supported in CHTML.
protected override bool OnAttributeRender(string name, string value, HtmlTextWriterAttribute key)
{
if (String.Equals("bgcolor", name))
{
return false;
}
// Call the ChtmlTextWriter version of the
// the OnAttributeRender method.
return base.OnAttributeRender(name, value, key);
}
}
// Derive from the WebControlAdapter class,
// provide a CreateCustomChtmlTextWriter
// method to attach to the custom writer.
public class ChtmlCustomPageAdapter : WebControlAdapter
{
protected internal ChtmlTextWriter CreateCustomChtmlTextWriter(
TextWriter writer)
{
return new CustomChtmlTextWriter(writer);
}
}
}
' Create a class that derives from the
' ChtmlTextWriter class.
Imports System.IO
Imports System.Web.UI
Imports System.Web.UI.WebControls.Adapters
Namespace AspNet.Samples.VB
Public Class CustomChtmlTextWriter
Inherits ChtmlTextWriter
' Create two constructors for the new
' text writer.
Public Sub New(ByVal writer As TextWriter)
MyClass.New(writer, DefaultTabString)
End Sub
Public Sub New(ByVal writer As TextWriter, ByVal tabString As String)
MyBase.New(writer, tabString)
End Sub
' Override the OnAttributeRender method to
' not render the bgcolor attribute, which is
' not supported in CHTML.
Protected Overrides Function OnAttributeRender(ByVal name As String, ByVal value As String, ByVal key As HtmlTextWriterAttribute) As Boolean
If (String.Equals("bgcolor", name)) Then
Return False
End If
' Call the ChtmlTextWriter version of
' the OnAttributeRender method.
MyBase.OnAttributeRender(name, value, key)
End Function
End Class
' Derive from the WebControlAdapter class,
' provide a CreateCustomChtmlTextWriter
' method to attach the custom writer.
Public Class ChtmlCustomPageAdapter
Inherits WebControlAdapter
Protected Friend Function CreateCustomChtmlTextWriter( _
ByVal writer As TextWriter) As ChtmlTextWriter
Return New CustomChtmlTextWriter(writer)
End Function
End Class
End Namespace
설명
ChtmlTextWriter 클래스의 instance 및 문자열을 매개 변수로 사용하는 생성자는 클래스의 TextWriterChtmlTextWriter instance 만들 때 동일한 매개 변수를 사용하는 생성자를 호출 Html32TextWriter 합니다.