Html32TextWriter 생성자
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
Html32TextWriter 클래스의 새 인스턴스를 초기화합니다.
오버로드
Html32TextWriter(TextWriter) |
요청한 브라우저에 줄 들여쓰기가 필요할 때 Html32TextWriter 필드에 지정된 줄 들여쓰기를 사용하는 DefaultTabString 클래스의 새 인스턴스를 초기화합니다. |
Html32TextWriter(TextWriter, String) |
지정한 줄 들여쓰기를 사용하는 Html32TextWriter 클래스의 새 인스턴스를 초기화합니다. |
Html32TextWriter(TextWriter)
요청한 브라우저에 줄 들여쓰기가 필요할 때 Html32TextWriter 필드에 지정된 줄 들여쓰기를 사용하는 DefaultTabString 클래스의 새 인스턴스를 초기화합니다.
public:
Html32TextWriter(System::IO::TextWriter ^ writer);
public Html32TextWriter (System.IO.TextWriter writer);
new System.Web.UI.Html32TextWriter : System.IO.TextWriter -> System.Web.UI.Html32TextWriter
Public Sub New (writer As TextWriter)
매개 변수
- writer
- TextWriter
HTML 내용을 렌더링하는 TextWriter입니다.
예제
다음 코드 예제에서는 사용 하는 방법에 설명 합니다 에서 파생 Html32TextWriter 되는 사용자 지정 클래스는 클래스입니다. 클래스에서 직접 또는 간접적으로 HtmlTextWriter 파생되는 모든 클래스에 대한 표준인 두 개의 생성자가 있습니다.
using System.IO;
using System.Web.UI;
namespace Examples.AspNet
{
public class CustomHtml32TextWriter : Html32TextWriter
{
// Create a constructor for the class
// that takes a TextWriter as a parameter.
public CustomHtml32TextWriter(TextWriter writer)
: this(writer, DefaultTabString)
{
}
// Create a constructor for the class that takes
// a TextWriter and a string as parameters.
public CustomHtml32TextWriter(TextWriter writer, String tabString)
: base(writer, tabString)
{
}
// Override the RenderBeforeContent method to render
// styles before rendering the content of a <th> element.
protected override string RenderBeforeContent()
{
// Check the TagKey property. If its value is
// HtmlTextWriterTag.TH, check the value of the
// SupportsBold property. If true, return the
// opening tag of a <b> element; otherwise, render
// the opening tag of a <font> element with a color
// attribute set to the hexadecimal value for red.
if (TagKey == HtmlTextWriterTag.Th)
{
if (SupportsBold)
return "<b>";
else
return "<font color=\"FF0000\">";
}
// Check whether the element being rendered
// is an <H4> element. If it is, check the
// value of the SupportsItalic property.
// If true, render the opening tag of the <i> element
// prior to the <H4> element's content; otherwise,
// render the opening tag of a <font> element
// with a color attribute set to the hexadecimal
// value for navy blue.
if (TagKey == HtmlTextWriterTag.H4)
{
if (SupportsItalic)
return "<i>";
else
return "<font color=\"000080\">";
}
// Call the base method.
return base.RenderBeforeContent();
}
// Override the RenderAfterContent method to close
// styles opened during the call to the RenderBeforeContent
// method.
protected override string RenderAfterContent()
{
// Check whether the element being rendered is a <th> element.
// If so, and the requesting device supports bold formatting,
// render the closing tag of the <b> element. If not,
// render the closing tag of the <font> element.
if (TagKey == HtmlTextWriterTag.Th)
{
if (SupportsBold)
return "</b>";
else
return "</font>";
}
// Check whether the element being rendered is an <H4>.
// element. If so, and the requesting device supports italic
// formatting, render the closing tag of the <i> element.
// If not, render the closing tag of the <font> element.
if (TagKey == HtmlTextWriterTag.H4)
{
if (SupportsItalic)
return "</i>";
else
return "</font>";
}
// Call the base method
return base.RenderAfterContent();
}
// Override the RenderBeforeTag method to render the
// opening tag of a <small> element to modify the text size of
// any <a> elements that this writer encounters.
protected override string RenderBeforeTag()
{
// Check whether the element being rendered is an
// <a> element. If so, render the opening tag
// of the <small> element; otherwise, call the base method.
if (TagKey == HtmlTextWriterTag.A)
return "<small>";
return base.RenderBeforeTag();
}
// Override the RenderAfterTag method to render
// close any elements opened in the RenderBeforeTag
// method call.
protected override string RenderAfterTag()
{
// Check whether the element being rendered is an
// <a> element. If so, render the closing tag of the
// <small> element; otherwise, call the base method.
if (TagKey == HtmlTextWriterTag.A)
return "</small>";
return base.RenderAfterTag();
}
}
}
' Create a custom HtmlTextWriter class that overrides
' the RenderBeforeContent and RenderAfterContent methods.
Imports System.IO
Imports System.Web.UI
Namespace Examples.AspNet
Public Class CustomHtml32TextWriter
Inherits Html32TextWriter
' Create a constructor for the class
' that takes a TextWriter as a parameter.
Public Sub New(ByVal writer As TextWriter)
Me.New(writer, DefaultTabString)
End Sub
' Create a constructor for the class that takes
' a TextWriter and a string as parameters.
Public Sub New(ByVal writer As TextWriter, ByVal tabString As String)
MyBase.New(writer, tabString)
End Sub
' Override the RenderBeforeContent method to render
' styles before rendering the content of a <th> element.
Protected Overrides Function RenderBeforeContent() As String
' Check the TagKey property. If its value is
' HtmlTextWriterTag.TH, check the value of the
' SupportsBold property. If true, return the
' opening tag of a <b> element; otherwise, render
' the opening tag of a <font> element with a color
' attribute set to the hexadecimal value for red.
If TagKey = HtmlTextWriterTag.Th Then
If (SupportsBold) Then
Return "<b>"
Else
Return "<font color=""FF0000"">"
End If
End If
' Check whether the element being rendered
' is an <H4> element. If it is, check the
' value of the SupportsItalic property.
' If true, render the opening tag of the <i> element
' prior to the <H4> element's content; otherwise,
' render the opening tag of a <font> element
' with a color attribute set to the hexadecimal
' value for navy blue.
If TagKey = HtmlTextWriterTag.H4 Then
If (SupportsItalic) Then
Return "<i>"
Else
Return "<font color=""000080"">"
End If
End If
' Call the base method.
Return MyBase.RenderBeforeContent()
End Function
' Override the RenderAfterContent method to close
' styles opened during the call to the RenderBeforeContent
' method.
Protected Overrides Function RenderAfterContent() As String
' Check whether the element being rendered is a <th> element.
' If so, and the requesting device supports bold formatting,
' render the closing tag of the <b> element. If not,
' render the closing tag of the <font> element.
If TagKey = HtmlTextWriterTag.Th Then
If SupportsBold Then
Return "</b>"
Else
Return "</font>"
End If
End If
' Check whether the element being rendered is an <H4>.
' element. If so, and the requesting device supports italic
' formatting, render the closing tag of the <i> element.
' If not, render the closing tag of the <font> element.
If TagKey = HtmlTextWriterTag.H4 Then
If (SupportsItalic) Then
Return "</i>"
Else
Return "</font>"
End If
End If
' Call the base method.
Return MyBase.RenderAfterContent()
End Function
' Override the RenderBeforeTag method to render the
' opening tag of a <small> element to modify the text size of
' any <a> elements that this writer encounters.
Protected Overrides Function RenderBeforeTag() As String
' Check whether the element being rendered is an
' <a> element. If so, render the opening tag
' of the <small> element; otherwise, call the base method.
If TagKey = HtmlTextWriterTag.A Then
Return "<small>"
End If
Return MyBase.RenderBeforeTag()
End Function
' Override the RenderAfterTag method to render
' close any elements opened in the RenderBeforeTag
' method call.
Protected Overrides Function RenderAfterTag() As String
' Check whether the element being rendered is an
' <a> element. If so, render the closing tag of the
' <small> element; otherwise, call the base method.
If TagKey = HtmlTextWriterTag.A Then
Return "</small>"
End If
Return MyBase.RenderAfterTag()
End Function
End Class
End Namespace
설명
Html32TextWriter 생성자는 다음 두 매개 변수가 있는 두 번째 버전으로 필드 값을 전달 DefaultTabString 합니다.
writer
클래스의 TextWriter instance 사용합니다.tabString
줄 들여쓰기를 정의하는 문자열을 사용합니다.
적용 대상
Html32TextWriter(TextWriter, String)
지정한 줄 들여쓰기를 사용하는 Html32TextWriter 클래스의 새 인스턴스를 초기화합니다.
public:
Html32TextWriter(System::IO::TextWriter ^ writer, System::String ^ tabString);
public Html32TextWriter (System.IO.TextWriter writer, string tabString);
new System.Web.UI.Html32TextWriter : System.IO.TextWriter * string -> System.Web.UI.Html32TextWriter
Public Sub New (writer As TextWriter, tabString As String)
매개 변수
- writer
- TextWriter
HTML 3.2 내용을 렌더링하는 TextWriter입니다.
예제
다음 코드 예제에서는 사용 하는 방법에 설명 합니다 에서 파생 Html32TextWriter 되는 사용자 지정 클래스는 클래스입니다. 클래스에서 직접 또는 간접적으로 HtmlTextWriter 파생되는 모든 클래스에 대한 표준인 두 개의 생성자가 있습니다.
using System.IO;
using System.Web.UI;
namespace Examples.AspNet
{
public class CustomHtml32TextWriter : Html32TextWriter
{
// Create a constructor for the class
// that takes a TextWriter as a parameter.
public CustomHtml32TextWriter(TextWriter writer)
: this(writer, DefaultTabString)
{
}
// Create a constructor for the class that takes
// a TextWriter and a string as parameters.
public CustomHtml32TextWriter(TextWriter writer, String tabString)
: base(writer, tabString)
{
}
// Override the RenderBeforeContent method to render
// styles before rendering the content of a <th> element.
protected override string RenderBeforeContent()
{
// Check the TagKey property. If its value is
// HtmlTextWriterTag.TH, check the value of the
// SupportsBold property. If true, return the
// opening tag of a <b> element; otherwise, render
// the opening tag of a <font> element with a color
// attribute set to the hexadecimal value for red.
if (TagKey == HtmlTextWriterTag.Th)
{
if (SupportsBold)
return "<b>";
else
return "<font color=\"FF0000\">";
}
// Check whether the element being rendered
// is an <H4> element. If it is, check the
// value of the SupportsItalic property.
// If true, render the opening tag of the <i> element
// prior to the <H4> element's content; otherwise,
// render the opening tag of a <font> element
// with a color attribute set to the hexadecimal
// value for navy blue.
if (TagKey == HtmlTextWriterTag.H4)
{
if (SupportsItalic)
return "<i>";
else
return "<font color=\"000080\">";
}
// Call the base method.
return base.RenderBeforeContent();
}
// Override the RenderAfterContent method to close
// styles opened during the call to the RenderBeforeContent
// method.
protected override string RenderAfterContent()
{
// Check whether the element being rendered is a <th> element.
// If so, and the requesting device supports bold formatting,
// render the closing tag of the <b> element. If not,
// render the closing tag of the <font> element.
if (TagKey == HtmlTextWriterTag.Th)
{
if (SupportsBold)
return "</b>";
else
return "</font>";
}
// Check whether the element being rendered is an <H4>.
// element. If so, and the requesting device supports italic
// formatting, render the closing tag of the <i> element.
// If not, render the closing tag of the <font> element.
if (TagKey == HtmlTextWriterTag.H4)
{
if (SupportsItalic)
return "</i>";
else
return "</font>";
}
// Call the base method
return base.RenderAfterContent();
}
// Override the RenderBeforeTag method to render the
// opening tag of a <small> element to modify the text size of
// any <a> elements that this writer encounters.
protected override string RenderBeforeTag()
{
// Check whether the element being rendered is an
// <a> element. If so, render the opening tag
// of the <small> element; otherwise, call the base method.
if (TagKey == HtmlTextWriterTag.A)
return "<small>";
return base.RenderBeforeTag();
}
// Override the RenderAfterTag method to render
// close any elements opened in the RenderBeforeTag
// method call.
protected override string RenderAfterTag()
{
// Check whether the element being rendered is an
// <a> element. If so, render the closing tag of the
// <small> element; otherwise, call the base method.
if (TagKey == HtmlTextWriterTag.A)
return "</small>";
return base.RenderAfterTag();
}
}
}
' Create a custom HtmlTextWriter class that overrides
' the RenderBeforeContent and RenderAfterContent methods.
Imports System.IO
Imports System.Web.UI
Namespace Examples.AspNet
Public Class CustomHtml32TextWriter
Inherits Html32TextWriter
' Create a constructor for the class
' that takes a TextWriter as a parameter.
Public Sub New(ByVal writer As TextWriter)
Me.New(writer, DefaultTabString)
End Sub
' Create a constructor for the class that takes
' a TextWriter and a string as parameters.
Public Sub New(ByVal writer As TextWriter, ByVal tabString As String)
MyBase.New(writer, tabString)
End Sub
' Override the RenderBeforeContent method to render
' styles before rendering the content of a <th> element.
Protected Overrides Function RenderBeforeContent() As String
' Check the TagKey property. If its value is
' HtmlTextWriterTag.TH, check the value of the
' SupportsBold property. If true, return the
' opening tag of a <b> element; otherwise, render
' the opening tag of a <font> element with a color
' attribute set to the hexadecimal value for red.
If TagKey = HtmlTextWriterTag.Th Then
If (SupportsBold) Then
Return "<b>"
Else
Return "<font color=""FF0000"">"
End If
End If
' Check whether the element being rendered
' is an <H4> element. If it is, check the
' value of the SupportsItalic property.
' If true, render the opening tag of the <i> element
' prior to the <H4> element's content; otherwise,
' render the opening tag of a <font> element
' with a color attribute set to the hexadecimal
' value for navy blue.
If TagKey = HtmlTextWriterTag.H4 Then
If (SupportsItalic) Then
Return "<i>"
Else
Return "<font color=""000080"">"
End If
End If
' Call the base method.
Return MyBase.RenderBeforeContent()
End Function
' Override the RenderAfterContent method to close
' styles opened during the call to the RenderBeforeContent
' method.
Protected Overrides Function RenderAfterContent() As String
' Check whether the element being rendered is a <th> element.
' If so, and the requesting device supports bold formatting,
' render the closing tag of the <b> element. If not,
' render the closing tag of the <font> element.
If TagKey = HtmlTextWriterTag.Th Then
If SupportsBold Then
Return "</b>"
Else
Return "</font>"
End If
End If
' Check whether the element being rendered is an <H4>.
' element. If so, and the requesting device supports italic
' formatting, render the closing tag of the <i> element.
' If not, render the closing tag of the <font> element.
If TagKey = HtmlTextWriterTag.H4 Then
If (SupportsItalic) Then
Return "</i>"
Else
Return "</font>"
End If
End If
' Call the base method.
Return MyBase.RenderAfterContent()
End Function
' Override the RenderBeforeTag method to render the
' opening tag of a <small> element to modify the text size of
' any <a> elements that this writer encounters.
Protected Overrides Function RenderBeforeTag() As String
' Check whether the element being rendered is an
' <a> element. If so, render the opening tag
' of the <small> element; otherwise, call the base method.
If TagKey = HtmlTextWriterTag.A Then
Return "<small>"
End If
Return MyBase.RenderBeforeTag()
End Function
' Override the RenderAfterTag method to render
' close any elements opened in the RenderBeforeTag
' method call.
Protected Overrides Function RenderAfterTag() As String
' Check whether the element being rendered is an
' <a> element. If so, render the closing tag of the
' <small> element; otherwise, call the base method.
If TagKey = HtmlTextWriterTag.A Then
Return "</small>"
End If
Return MyBase.RenderAfterTag()
End Function
End Class
End Namespace
추가 정보
적용 대상
.NET