用QueryString提交带有特殊字符的参数
字符 特殊字符的含义 URL编码
# 用来标志特定的文档位置 %23
% 对特殊字符进行编码 %25
& 分隔不同的变量值对 %26
+ 在变量值中表示空格 %2B
\ 表示目录路径 %2F
= 用来连接键和值 %3D
? 表示查询字符串的开始 %3F
当传递的参数中含有这些值时,接收页面无法接收该值,那该怎么办呢?使用URLEncode方法进行编码如
str=“a+b”
Response.Redirect(“***.aspx?str=”+Server.UrlEncode(str))
在跳转页面Request.QueryString(“str”)就可以了
也可以直接替换
CTS中的处理示例:
function btn_boiler_onclick() {
varunitmsg = document.getElementById('unitName');
var unitname = unitmsg.value;
varunitmsg1 = document.getElementById('unitID');
varunitid = unitmsg1.value;
self.location = "Monitor_Boiler.aspx?unitName="+ unitname.replace("#", "%23")+ "&unit_id=" + unitid;
}
其中的#号被替换为%23