日期:2014-05-17 浏览次数:20540 次
StringBuilder sb = new StringBuilder(); foreach (char c in nam_cust.Text) sb.Append("&#" + (int)c); question.Nam_Cust = sb.ToString();
<%@ Page Language="C#" EnableViewState="true" AutoEventWireup="true" ValidateRequest="false" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { TextBox1.Text = "我現在想做的就是在綁定之前把字符轉碼再轉換回來,然後再綁定DataSet,不知道哪位大牛能指教一下,打這麼多的字也不容易啊,希望大家能夠幫幫忙,新號沒分"; TextBox2.Text = Microsoft.Security.Application.Encoder.HtmlEncode(TextBox1.Text); TextBox3.Text = System.Web.HttpUtility.HtmlDecode(TextBox2.Text); } } protected void Button1_Click(object sender, EventArgs e) { TextBox2.Text = Microsoft.Security.Application.Encoder.HtmlEncode(TextBox1.Text); } protected void Button2_Click(object sender, EventArgs e) { TextBox3.Text = System.Web.HttpUtility.HtmlDecode(TextBox2.Text); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>dddd</title> </head> <body> <form id="form1" runat="server"> <asp:TextBox ID="TextBox1" runat="server" Height="187px" TextMode="MultiLine" Width="1230px"></asp:TextBox> <br /> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="编码" /> <p> <asp:TextBox ID="TextBox2" runat="server" Height="187px" TextMode="MultiLine" Width="1230px"></asp:TextBox> </p> <p> <asp:Button ID="Button2" runat="server" Text="解码" onclick="Button2_Click" /> </p> <p> <asp:TextBox ID="TextBox3" runat="server" Height="187px" TextMode="MultiLine" Width="1230px"></asp:TextBox> </p> </form> </body> </html>