HtmlTextWriter.WriteEncodedText(String) HtmlTextWriter.WriteEncodedText(String) HtmlTextWriter.WriteEncodedText(String) HtmlTextWriter.WriteEncodedText(String) Method

定義

為要求的裝置編碼指定的文字,然後將其寫入輸出資料流。Encodes the specified text for the requesting device, and then writes it to the output stream.

public:
 virtual void WriteEncodedText(System::String ^ text);
public virtual void WriteEncodedText (string text);
abstract member WriteEncodedText : string -> unit
override this.WriteEncodedText : string -> unit
Public Overridable Sub WriteEncodedText (text As String)

參數

text
String String String String

要編碼及寫入輸出資料流的文字字串。The text string to encode and write to the output stream.

例外狀況

範例

下列程式碼範例示範如何使用WriteEncodedText方法,將編碼的標記&lt;custID&gt; &amp; &lt;invoice#&gt;寫入輸出資料流程。The following code example shows how to use the WriteEncodedText method to write the encoded markup &lt;custID&gt; &amp; &lt;invoice#&gt; to the output stream. 方法會寫入<br />WriteBreakThe WriteBreak method writes <br />.

// Assign a value to a string variable,
// encode it, and write it to a page.
colHeads = "<custID> & <invoice#>"; 
writer.WriteEncodedText(colHeads);
writer.WriteBreak();
' Assign a value to a string variable,
' encode it, and write it to a page.
colHeads = "<custID> & <invoice#>" 
writer.WriteEncodedText(colHeads)
writer.WriteBreak()

備註

當字串WriteEncodedText包含角括弧(<或 >)或連字號(&)時,請使用方法。Use the WriteEncodedText method when a string contains angle brackets (< or >) or an ampersand (&).

方法會00A0使用方法來執行編碼,而且也會將 Unicode 字元轉換&nbsp;成。 HtmlEncode WriteEncodedTextThe WriteEncodedText method uses the HtmlEncode method to perform the encoding and also converts Unicode character 00A0 to &nbsp;.

適用於

另請參閱