HtmlTextWriter.InnerWriter 屬性

定義

取得或設定寫入標記項目內部內容的文字寫入器。Gets or sets the text writer that writes the inner content of the markup element.

public:
 property System::IO::TextWriter ^ InnerWriter { System::IO::TextWriter ^ get(); void set(System::IO::TextWriter ^ value); };
public System.IO.TextWriter InnerWriter { get; set; }
member this.InnerWriter : System.IO.TextWriter with get, set
Public Property InnerWriter As TextWriter

屬性值

寫入內部標記內容的 TextWriterA TextWriter that writes the inner markup content.

範例

下列程式碼範例示範如何使用自訂的 Web 服務器控制項(衍生WebControl自類別)來Render覆寫方法。The following code example shows how to use a custom Web server control, derived from the WebControl class, that overrides the Render method. 它會使用HtmlTextWriter類別來<font>寫入元素。It uses the HtmlTextWriter class to write a <font> element. 在寫入元素的開頭標記之後,它會使用InnerWriter屬性來寫入字串"<br> The time on the server:" ,並將此字串DateTime.Now與屬性的值串連。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( 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.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.
        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
End Class

備註

內部標記內容是在標記語言專案的開頭和結束記號之間找到的文字。Inner markup content is the text found between the opening and closing tags of a markup language element.

如果屬性設定為屬於類別實例TextWriter的物件,則會注明此事實並儲存個別的參考。 HttpWriter InnerWriterIf 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.

適用於

另請參閱