c html text,ChtmlTextWriter

使用指定的行缩进初始化 ChtmlTextWriter 类的新实例。Initializes a new instance of the ChtmlTextWriter class with the specified line indentation.

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)

参数

The TextWriter that renders the markup content.

tabString

Indent 中定义的空格数。The number of spaces defined in the Indent.

示例

下面的代码示例演示如何创建一个名为的自定义类 CustomChtmlTextWriter ,该类派生自 ChtmlTextWriter 类。The following code example demonstrates how to create a custom class named CustomChtmlTextWriter that is derived from the ChtmlTextWriter class. 它创建两个构造函数,可用于创建自定义类的实例,其模式与从类直接或间接派生的所有类的模式相同 HtmlTextWriter 。It creates two constructors that you can use to create an instance of the custom class with the same pattern as all classes that derive, directly or indirectly, from the HtmlTextWriter class.

// 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

注解

The ChtmlTextWriter constructor, which takes both an instance of the TextWriter class and a string as parameters, calls the Html32TextWriter constructor that takes the same parameters when it creates an instance of the ChtmlTextWriter class.

适用于

1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。、可私 6信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。、可私 6信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 、可私信博6主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值