C#
public TextWriter Output { get; }
Visual C++
public: property TextWriter^ Output { TextWriter^ get (); }
J#
/** @property */ public TextWriter get_Output()
JScript
public function get Output () : TextWriter
示例
<!---->
下面的示例是一个包含 TextBox 控件的 ASP.NET 页,该控件的 TextMode 属性设置为 MultiLine。该页的代码接受用户在 TextMode 中输入的文本,然后使用 HtmlEncode()()() 方法对这些文本进行 HTML 编码,再使用 Output 属性将编码后的字符串显示到该页中。
Visual Basic
<%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> ' When the page is posted back, the text box's ' Text property value is HTML encoded and sent ' sent to the current response. Private Sub btnSubmit_Click(sender As Object, e As EventArgs) If (IsPostBack = True) Server.HtmlEncode(txtSubmitString.Text, Response.Output) End If End Sub </script> <html > <head> <title>ASP.NET Example</title> </head> <body> <form id="form1" runat="server"> <p style="font-family:Tahoma; font-size:12"> Enter your comments here: </p> <p> <asp:TextBox id="txtSubmitString" runat="server" Width="181px" TextMode="MultiLine"></asp:TextBox> </p> <p> <asp:Button id="btnSubmit" οnclick="btnSubmit_Click" runat="server" Text="Submit"></asp:Button> </p> <p> <asp:Label id="lblEncodedString" runat="server"></asp:Label> </p> </form> </body> </html>
C#
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> // When the page is posted back, the text box's // Text property value is HTML encoded and sent // sent to the current Response. void btnSubmit_Click(object sender, EventArgs e) { if (IsPostBack) { Server.HtmlEncode(txtSubmitString.Text, Response.Output); } } </script> <html > <head> <title>ASP.NET Example</title> </head> <body> <form id="form1" runat="server"> <p style="font-family:Tahoma; font-size:12"> Enter your comments here: </p> <p> <asp:TextBox id="txtSubmitString" runat="server" Width="181px" TextMode="MultiLine"></asp:TextBox> </p> <p> <asp:Button id="btnSubmit" οnclick="btnSubmit_Click" runat="server" Text="Submit"></asp:Button> </p> <p> <asp:Label id="lblEncodedString" runat="server"></asp:Label> </p> </form> </body> </html>