Export (0) Print
Expand All

HtmlTextWriter.InnerWriter Property

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

[Visual Basic]
Public Property InnerWriter As TextWriter
[C#]
public TextWriter InnerWriter {get; set;}
[C++]
public: __property TextWriter* get_InnerWriter();
public: __property void set_InnerWriter(TextWriter*);
[JScript]
public function get InnerWriter() : TextWriter;
public function set InnerWriter(TextWriter);

Property Value

A TextWriter object that writes the inner HTML content.

Remarks

Inner HTML content is the text found between the opening and closing tags of an HTML element.

Example

[Visual Basic, C#, C++] The following example shows a custom Web server control, derived from the WebControl class, that overrides the Render method. It uses the HtmlTextWriter class associated with that method call to write an HTML <font> element. Once it writes the opening tag of the element, it uses the InnerWriter property to write the HTML string "<br> The time on the server:" and concatenates this string with the value of the DateTime.Now property.

[Visual Basic] 
' Write the opening tag of an HTML 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.
Dim innerTextWriter As TextWriter = 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")
   End Sub 'Render
End Class 'FirstControl 

[C#] 
// Write the opening tag of an HTML 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");
    }

[C++] 
// Write the opening tag of an HTML Font element.
writer->WriteBeginTag(S"font");
// Write a Color style attribute to the opening tag
// of the Font element and set its value to red.
writer->WriteAttribute(S"color", S"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(String::Concat(Message, S"<br> The time on the server : ",
   System::DateTime::Now.ToLongTimeString()));

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

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

HtmlTextWriter Class | HtmlTextWriter Members | System.Web.UI Namespace

Show:
© 2014 Microsoft