富贵资源网 Design By www.hznty.com

本文实例讲述了asp.net+js实现批量编码与解码的方法。分享给大家供大家参考,具体如下:

<%@ 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="/UploadFiles/2021-04-02/jquery-1.3.2.min.js">

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'>服务器得到的值(解码前):<br/>";
      foreach (string s in Request.Form.AllKeys)
      {
        msg += string.Format("{0}:{1}<br/>", s, Request.Form[s]);
      }
      msg += "服务器得到的值(解码后):<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();
    }
  }
}

希望本文所述对大家asp.net程序设计有所帮助。

富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com