HtmlTextWriter.Write Method

Definition

Writes the specified data type to the output stream, along with any pending tab spacing.

Overloads

Name Description
Write(Boolean)

Writes the text representation of a Boolean value to the output stream, along with any pending tab spacing.

Write(Char)

Writes the text representation of a Unicode character to the output stream, along with any pending tab spacing.

Write(Char[])

Writes the text representation of an array of Unicode characters to the output stream, along with any pending tab spacing.

Write(Double)

Writes the text representation of a double-precision floating-point number to the output stream, along with any pending tab spacing.

Write(Int32)

Writes the text representation of a 32-byte signed integer to the output stream, along with any pending tab spacing.

Write(Int64)

Writes the text representation of a 64-byte signed integer to the output stream, along with any pending tab spacing.

Write(Object)

Writes the text representation of an object to the output stream, along with any pending tab spacing.

Write(Single)

Writes the text representation of a single-precision floating-point number to the output stream, along with any pending tab spacing.

Write(String)

Writes the specified string to the output stream, along with any pending tab spacing.

Write(String, Object)

Writes a tab string and a formatted string to the output stream, using the same semantics as the Format(String, Object) method, along with any pending tab spacing.

Write(String, Object[])

Writes a formatted string that contains the text representation of an object array to the output stream, along with any pending tab spacing. This method uses the same semantics as the Format(String, Object[]) method.

Write(Char[], Int32, Int32)

Writes the text representation of a subarray of Unicode characters to the output stream, along with any pending tab spacing.

Write(String, Object, Object)

Writes a formatted string that contains the text representation of two objects to the output stream, along with any pending tab spacing. This method uses the same semantics as the Format(String, Object, Object) method.

Write(Boolean)

Writes the text representation of a Boolean value to the output stream, along with any pending tab spacing.

public:
 override void Write(bool value);
public override void Write(bool value);
override this.Write : bool -> unit
Public Overrides Sub Write (value As Boolean)

Parameters

value
Boolean

The Boolean to write to the output stream.

Remarks

The Write method generates any tabs that are pending, and then calls the Write base method.

See also

Applies to

Write(Char)

Writes the text representation of a Unicode character to the output stream, along with any pending tab spacing.

public:
 override void Write(char value);
public override void Write(char value);
override this.Write : char -> unit
Public Overrides Sub Write (value As Char)

Parameters

value
Char

The Unicode character to write to the output stream.

Examples

The following code example demonstrates using the Write method to end the opening tag of an <img> element by using the TagRightChar constant.

This code example renders the following markup:

<img alt="A custom image">

</img>

// Create a manually rendered <img> element
// that contains an alt attribute.
writer.WriteBeginTag("img");
writer.WriteAttribute("alt", "A custom image.");
writer.Write(HtmlTextWriter.TagRightChar);
writer.WriteEndTag("img");
' Create a manually rendered <img> element
' that contains an alt attribute.
writer.WriteBeginTag("img")
writer.WriteAttribute("alt", "A custom image.")
writer.Write(HtmlTextWriter.TagRightChar)
writer.WriteEndTag("img")

Remarks

The Write method generates any tabs that are pending, and then calls the Write base method.

See also

Applies to

Write(Char[])

Writes the text representation of an array of Unicode characters to the output stream, along with any pending tab spacing.

public:
 override void Write(cli::array <char> ^ buffer);
public override void Write(char[] buffer);
override this.Write : char[] -> unit
Public Overrides Sub Write (buffer As Char())

Parameters

buffer
Char[]

The array of Unicode characters to write to the output stream.

Examples

This section provides two code examples. The first one demonstrates how to create an array of characters. The second one demonstrates how to use the array.

These code examples generate the following markup:

<label>

hello world

</label>

The following code example demonstrates how to create an array of characters that spell out hello world. Included in the array is the SpaceChar field, which creates a space between the two words.

private char[] testChars = {'h', 'e', 'l', 'l', 'o',
    HtmlTextWriter.SpaceChar ,'w', 'o', 'r', 'l', 'd'};
Private testChars() As Char = _
    {"h"c, "e"c, "l"c, "l"c, "o"c, _
    HtmlTextWriter.SpaceChar, "w"c, "o"c, "r"c, "l"c, "d"c}

The following code example demonstrates how to use the Write method to render the hello world character array created in the preceding code example to a page, when the control that contains this example code is included in a page.

// Render a character array as the 
// contents of a <label> element.
writer.RenderBeginTag(HtmlTextWriterTag.Label);
writer.Write(testChars);
writer.RenderEndTag();
' Render a character array as the 
' contents of a <label> element.
writer.RenderBeginTag(HtmlTextWriterTag.Label)
writer.Write(testChars)
writer.RenderEndTag()

Remarks

The Write method generates any tabs that are pending, and then calls the Write base method.

See also

Applies to

Write(Double)

Writes the text representation of a double-precision floating-point number to the output stream, along with any pending tab spacing.

public:
 override void Write(double value);
public override void Write(double value);
override this.Write : double -> unit
Public Overrides Sub Write (value As Double)

Parameters

value
Double

The double-precision floating-point number to write to the output stream.

Examples

The following code example shows how to use the Write method to render the value of the Double.MaxValue field.

This code example generates the following markup:

<label>

1.79769313486232E+308

</label>

// Use the Write(Double) method to render
// the MaxValue field of the Double structure. 
writer.RenderBeginTag(HtmlTextWriterTag.Label);
writer.Write(Double.MaxValue);
writer.RenderEndTag();
' Use the WriteLine(Double) method to render
' the MaxValue field of the Double structure. 
writer.RenderBeginTag(HtmlTextWriterTag.Label)
writer.WriteLine(Double.MaxValue)
writer.RenderEndTag()

Remarks

The Write method generates any tabs that are pending, and then calls the Write base method.

See also

Applies to

Write(Int32)

Writes the text representation of a 32-byte signed integer to the output stream, along with any pending tab spacing.

public:
 override void Write(int value);
public override void Write(int value);
override this.Write : int -> unit
Public Overrides Sub Write (value As Integer)

Parameters

value
Int32

The 32-byte signed integer to write to the output stream.

Remarks

The Write method generates any tabs that are pending, and then calls the Write base method.

See also

Applies to

Write(Int64)

Writes the text representation of a 64-byte signed integer to the output stream, along with any pending tab spacing.

public:
 override void Write(long value);
public override void Write(long value);
override this.Write : int64 -> unit
Public Overrides Sub Write (value As Long)

Parameters

value
Int64

The 64-byte signed integer to write to the output stream.

Remarks

The Write method generates any tabs that are pending, and then calls the Write base method.

See also

Applies to

Write(Object)

Writes the text representation of an object to the output stream, along with any pending tab spacing.

public:
 override void Write(System::Object ^ value);
public override void Write(object value);
override this.Write : obj -> unit
Public Overrides Sub Write (value As Object)

Parameters

value
Object

The object to write to the output stream.

Examples

The following code example shows how to use the Write method to render the value of the