asp.net+js實(shí)現(xiàn)批量編碼與解碼的方法
本文實(shí)例講述了asp.net+js實(shí)現(xiàn)批量編碼與解碼的方法。分享給大家供大家參考,具體如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <mce:script src="jquery-1.3.2.min.js" mce_src="jquery-1.3.2.min.js" type="text/javascript"></mce:script> <mce:script type="text/javascript"><!-- var data = {}; data.Id = 1; data.Name = "1 & 2"; data.Desc = "<b> def </b>"; var clientMsg = ""; clientMsg+="<font color='green'>1: 客戶端編碼之前:<br/>"; for (var name in data) { clientMsg+=(name + ":" + data[name] + "<br/>"); } clientMsg += "1: 客戶端編碼之后:<br/>"; escapeData(data); for (var name in data) { clientMsg+=name + ":" + data[name] + "<br/>"; } clientMsg += "</font>"; $.post("Default.aspx", data, function (data) { document.write(clientMsg+"<br/>"+data); }); function escapeData(data) { for (var name in data) { data[name] = escape(data[name]); } } // --></mce:script> </head> <body> <form id="form1" runat="server"> <div id="divClient" style="color:Green;" mce_style="color:Green;" > </div> </form> </body> </html>
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 += "<font color='red'>服務(wù)器得到的值(解碼前):<br/>"; foreach (string s in Request.Form.AllKeys) { msg += string.Format("{0}:{1}<br/>", s, Request.Form[s]); } msg += "服務(wù)器得到的值(解碼后):<br/>"; foreach (string s in Request.Form.AllKeys) { msg += string.Format("{0}:{1}<br/>", s, HttpUtility.UrlDecode(Request.Form[s])); } msg += "</font>"; msg += string.Format("未編碼的字符解碼1ab&<b>小</b>:{0}",HttpUtility.UrlDecode("1ab&<b>小</b>")); ; Response.Write(msg); Response.End(); } } }
希望本文所述對(duì)大家asp.net程序設(shè)計(jì)有所幫助。
相關(guān)文章
asp.net 數(shù)據(jù)庫(kù)備份還原(sqlserver+access)
Asp.net 備份、還原Ms SQLServer及壓縮Access數(shù)據(jù)庫(kù)2008-11-11詳解ASP.NET Core中配置監(jiān)聽URLs的五種方式
這篇文章主要介紹了詳解ASP.NET Core中配置監(jiān)聽URLs的五種方式,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-04-04Asp.Net Core WebAPI使用Swagger時(shí)API隱藏和分組詳解
這篇文章主要給大家介紹了關(guān)于Asp.Net Core WebAPI使用Swagger時(shí)API隱藏和分組的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Asp.Net Core具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04Visual Studio卸載不完全問(wèn)題的解決方法
這篇文章主要為大家詳細(xì)介紹了Visual Studio卸載不完全問(wèn)題的解決方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-04-04ASP.NET?Core設(shè)置Ocelot網(wǎng)關(guān)限流
這篇文章介紹了ASP.NET?Core設(shè)置Ocelot網(wǎng)關(guān)限流的方法,文中通過(guò)示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-04-04.NET Core 2.1中HttpClientFactory的最佳實(shí)踐記錄
這篇文章主要給大家介紹了關(guān)于.NET Core 2.1中HttpClientFactory的最佳實(shí)踐記錄,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用.net core2.1具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起看看吧2018-08-08[c#]asp.ent下開發(fā)中Tag的開發(fā)技巧
[c#]asp.ent下開發(fā)中Tag的開發(fā)技巧...2007-05-05.NET Core中如何實(shí)現(xiàn)或使用對(duì)象池?
什么是對(duì)象池?簡(jiǎn)單來(lái)說(shuō)它就是一種為對(duì)象提供可復(fù)用性能力的軟件設(shè)計(jì)思路,對(duì)象池就是通過(guò)“借”和“還”這樣兩個(gè)動(dòng)作來(lái)保證對(duì)象可以被重復(fù)使用,這篇文章主要給大家介紹了關(guān)于.NET Core中如何實(shí)現(xiàn)或使用對(duì)象池的相關(guān)資料,需要的朋友可以參考下2021-07-07ASP.NET Core MVC學(xué)習(xí)教程之路由(Routing)
這篇文章主要給大家介紹了關(guān)于ASP.NET Core MVC學(xué)習(xí)教程之路由(Routing)的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用ASP.NET Core MVC具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-07-07