本文实例讲述了asp.net+js实现批量编码与解码的方法。分享给大家供大家参考,具体如下:
/p>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
C#代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request["Id"]!=null)
{
string msg = "";
msg += "服务器得到的值(解码前):
";
foreach (string s in Request.Form.AllKeys)
{
msg += string.Format("{0}:{1}
", s, Request.Form[s]);
}
msg += "服务器得到的值(解码后):
";
foreach (string s in Request.Form.AllKeys)
{
msg += string.Format("{0}:{1}
", s, HttpUtility.UrlDecode(Request.Form[s]));
}
msg += "";
msg += string.Format("未编码的字符解码1ab&小:{0}",HttpUtility.UrlDecode("1ab&小")); ;
Response.Write(msg);
Response.End();
}
}
}
希望本文所述对大家asp.net程序设计有所帮助。