HtmlTextWriter.InnerWriter Property

Gets or sets the text writer that writes the inner content of the markup element.

Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)

public TextWriter InnerWriter { get; set; }
/** @property */
public TextWriter get_InnerWriter ()

/** @property */
public void set_InnerWriter (TextWriter value)

public function get InnerWriter () : TextWriter

public function set InnerWriter (value : TextWriter)

Not applicable.

Property Value

A TextWriter that writes the inner markup content.

Inner markup content is the text found between the opening and closing tags of a markup language element.

If the InnerWriter property is set to a TextWriter object that is an instance of the HttpWriter class, this fact is noted and a separate reference is saved.

The following code example shows how to use a custom Web server control, derived from the WebControl class, that overrides the Render method. It uses the HtmlTextWriter class to write a <font> element. After it writes the opening tag of the element, it uses the InnerWriter property to write the string "<br> The time on the server:" and concatenates this string with the value of the DateTime.Now property.

    // Write the opening tag of a Font element.
    writer.WriteBeginTag("font");
    // Write a Color style attribute to the opening tag
    // of the Font element and set its value to red.
    writer.WriteAttribute("color", "red");
    // Write the closing character for the opening tag of
    // the Font element.
    writer.Write('>');

    // Use the InnerWriter property to create a TextWriter
    // object that will write the content found between
    // the opening and closing tags of the Font element.
    // Message is a string property of the control that 
    // overrides the Render method.
    TextWriter innerTextWriter = writer.InnerWriter;
    innerTextWriter.Write(Message + "<br> The time on the server :" + System.DateTime.Now.ToLongTimeString());

    // Write the closing tag of the Font element.
    writer.WriteEndTag("font");
}

// Write the opening tag of a Font element.
writer.WriteBeginTag("font");

// Write a Color style attribute to the opening tag
// of the Font element and set its value to red.
writer.WriteAttribute("color", "red");

// Write the closing character for the opening tag of
// the Font element.
writer.Write('>');

// Use the InnerWriter property to create a TextWriter
// object that will write the content found between
// the opening and closing tags of the Font element.
// Message is a string property of the control that 
// overrides the Render method.
TextWriter innerTextWriter = writer.get_InnerWriter();

innerTextWriter.Write(get_Message() + "<br> The time on the server :" 
    + System.DateTime.get_Now().ToLongTimeString());

// Write the closing tag of the Font element.
writer.WriteEndTag("font");

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show: