HtmlTextWriter.InnerWriter-Eigenschaft
Ruft den Textwriter ab, der den inneren Inhalt des Markupelements schreibt, oder legt diesen fest.
Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)
Syntax
'Declaration
Public Property InnerWriter As TextWriter
'Usage
Dim instance As HtmlTextWriter
Dim value As TextWriter
value = instance.InnerWriter
instance.InnerWriter = value
public TextWriter InnerWriter { get; set; }
public:
property TextWriter^ InnerWriter {
TextWriter^ get ();
void set (TextWriter^ value);
}
/** @property */
public TextWriter get_InnerWriter ()
/** @property */
public void set_InnerWriter (TextWriter value)
public function get InnerWriter () : TextWriter
public function set InnerWriter (value : TextWriter)
Eigenschaftenwert
Ein TextWriter, der den inneren Markupinhalt schreibt.
Hinweise
Der innere Markupinhalt ist der Text zwischen dem Start- und Endtag eines Elements der Markupsprache.
Wenn die InnerWriter-Eigenschaft auf ein TextWriter-Objekt festgelegt ist, das eine Instanz der HttpWriter-Klasse ist, wird dies erfasst und ein separater Verweis gespeichert.
Beispiel
Im folgenden Codebeispiel wird die Verwendung eines benutzerdefinierten Webserversteuerelements veranschaulicht, das von der WebControl-Klasse abgeleitet ist und die Render-Methode überschreibt. Es verwendet die HtmlTextWriter-Klasse, um ein <font>-Element zu schreiben. Nach dem Schreiben des Starttags des Elements wird mithilfe der InnerWriter-Eigenschaft die Zeichenfolge "<br> The time on the server:"
geschrieben, die dann mit dem Wert der DateTime.Now-Eigenschaft verkettet wird.
' 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.
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
// 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->InnerWriter;
innerTextWriter->Write( String::Concat( 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");
Plattformen
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
HtmlTextWriter-Klasse
HtmlTextWriter-Member
System.Web.UI-Namespace
TextWriter
HttpWriter
WebControl