您的位置:首页 > 理论基础 > 计算机网络

HttpResponse..::.Output 属性

2008-12-23 21:54 190 查看
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


属性值

类型:System.IO..::.TextWriter

支持到客户端的自定义输出的 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" onclick="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" onclick="btnSubmit_Click" runat="server" Text="Submit"></asp:Button>
</p>
<p>
<asp:Label id="lblEncodedString" runat="server"></asp:Label>
</p>
</form>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: