現在の HtmlTextWriter のすべてのバッファをクリアし、バッファ内のすべてのデータをテキスト ストリームに書き込みます。
Overrides Public Sub Flush()
[C#]
public override void Flush();
[C++]
public: void Flush();
[JScript]
public override function Flush();
使用例
[Visual Basic, C#, C++] HTML の Label 要素が表示された後に、 Control.Render メソッドのオーバーライドで Flush メソッドを呼び出すコード例を次に示します。
Public Class FirstControl
Inherits WebControl
'The message property.
Private myMessage As String = "Hello"
'Accessors for the message property.
Public Overridable Property Message() As [String]
Get
Return myMessage
End Get
Set(ByVal Value As [String])
myMessage = Value
End Set
End Property
Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
'Output the 'label' html tag
writer.WriteBeginTag("label")
'Output the space character.
writer.Write(HtmlTextWriter.SpaceChar)
'Output the string "style" followed by "=\"".
writer.Write(("style" + HtmlTextWriter.EqualsDoubleQuoteString))
'Output the style attribute "font-size".
writer.Write(("font-size" + HtmlTextWriter.StyleEqualsChar + "12pt"))
'Output a style attribute separator.
writer.Write(HtmlTextWriter.SemicolonChar)
'Output the style attribute "color".
writer.Write(("color" + HtmlTextWriter.StyleEqualsChar + "fuchsia"))
'Output the double quote character.
writer.Write(HtmlTextWriter.DoubleQuoteChar)
'Output the '>' character.
writer.Write(HtmlTextWriter.TagRightChar)
'Output the 'Message' property.
writer.Write(Message)
'Output the 'Message' property contents and the time on the server.
writer.Write(("<br>" + "<font color=""blue"">" + "The time on the server: " + System.DateTime.Now.ToLongTimeString() + "</font>"))
'Flush the contents of the 'HtmlTextWriter'.
writer.Flush()
End Sub 'Render
End Class 'FirstControl
[C#]
public class FirstControl : WebControl
{
// The message property.
private String message = "Hello";
// Accessors for the message property.
public virtual String Message
{
get {
return message;
}
set {
message = value;
}
}
protected override void Render(HtmlTextWriter writer)
{
// Output the 'label' html tag.
writer.WriteBeginTag("label");
// Output the space character.
writer.Write(HtmlTextWriter.SpaceChar);
// Output the string "style" followed by "=\"".
writer.Write("style" + HtmlTextWriter.EqualsDoubleQuoteString);
// Output the style attribute "font-size".
writer.Write("font-size" + HtmlTextWriter.StyleEqualsChar + "12pt");
// Output a style attribute separator.
writer.Write(HtmlTextWriter.SemicolonChar);
// Output the style attribute "color".
writer.Write("color" + HtmlTextWriter.StyleEqualsChar + "fuchsia");
// Output the double quote character.
writer.Write(HtmlTextWriter.DoubleQuoteChar);
// Output the '>' character.
writer.Write(HtmlTextWriter.TagRightChar);
// Output the 'Message' property.
writer.Write(Message);
// Output the 'Message' property contents and the time on the server.
writer.Write("<br>" + "<font color=\"blue\">" +
"The time on the server: " +
System.DateTime.Now.ToLongTimeString() +
"</font>");
// Flush the contents of the 'HtmlTextWriter'.
writer.Flush();
}
}
[C++]
public __gc class FirstControl : public WebControl
{
// The message property.
private:
String* message;
// Accessors for the message property.
public:
__property virtual String* get_Message() {
return message;
}
__property virtual void set_Message( String* value ) {
message = value;
}
protected:
void Render(HtmlTextWriter* writer)
{
// Output the 'label' html tag.
writer->WriteBeginTag(S"label");
// Output the space character.
writer->Write(HtmlTextWriter::SpaceChar);
// Output the string "style" followed by "=\"".
writer->Write(S"style{0}", HtmlTextWriter::EqualsDoubleQuoteString);
// Output the style attribute "font-size".
writer->Write(S"font-size{0}12pt",__box(HtmlTextWriter::StyleEqualsChar));
// Output a style attribute separator.
writer->Write(HtmlTextWriter::SemicolonChar);
// Output the style attribute "color".
writer->Write(S"color{0}fuchsia",__box(HtmlTextWriter::StyleEqualsChar));
// Output the double quote character.
writer->Write(HtmlTextWriter::DoubleQuoteChar);
// Output the '>' character.
writer->Write(HtmlTextWriter::TagRightChar);
// Output the 'Message' property.
writer->Write(Message);
// Output the 'Message' property contents and the time on the server.
writer->Write(S"<br><font color=\"blue\">The time on the server: {0}</font>",
System::DateTime::Now.ToLongTimeString() );
// Flush the contents of the 'HtmlTextWriter'.
writer->Flush();
}
};
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 2000, Windows XP Professional, Windows Server 2003 ファミリ
参照
HtmlTextWriter クラス | HtmlTextWriter メンバ | System.Web.UI 名前空間 | TextWriter