如何使用javascript传递查询字符串并在asp.net的代码隐藏页面中使用它?
目前,我正在使用JavaScript在对话框中打开一个页面,如下所示。我通过加密将查询字符串传递到列表页如何使用javascript传递查询字符串并在asp.net的代码隐藏页面中使用它?,javascript,asp.net,query-string,Javascript,Asp.net,Query String,目前,我正在使用JavaScript在对话框中打开一个页面,如下所示。我通过加密将查询字符串传递到列表页 function Popup() { if (document.getElementById("<%= Amount.ClientID %>").value != "") { var xorKey = 13; var Obj = window; var id = document.getEl
function Popup() {
if (document.getElementById("<%= Amount.ClientID %>").value != "") {
var xorKey = 13;
var Obj = window;
var id = document.getElementById("<%= id.ClientID %>").value + "-" + document.getElementById("<%= Amount.ClientID %>").value;
var result = "";
for (i = 0; i < id.length; ++i) {
param += String.fromCharCode(xorKey ^ id.charCodeAt(i));
}
window.showModalDialog("list.aspx?id=" + param, Obj, "dialogWidth:800px; dialogHeight:500px; dialogLeft:252px; dialogTop:120px; center:yes");
}
}
函数弹出(){
if(document.getElementById(“”.value!=“”){
var-xorKey=13;
var Obj=窗口;
var id=document.getElementById(“”.value+“-”+document.getElementById(“”.value);
var结果=”;
对于(i=0;i
现在在代码隐藏页上,我使用以下代码:
string id = Request.QueryString[0].ToString();
StringBuilder inSb = new StringBuilder(id);
StringBuilder outSb = new StringBuilder(id.Length);
char c;
for (int i = 0; i < id.Length; i++)
{
c = inSb[i];
c = (char)(c ^ 13); /// remember to use the same XORkey value you used in javascript
outSb.Append(c);
}
string[] idvalue = outSb.ToString().Split('-');
id = idvalue[0].ToString();
string id=Request.QueryString[0].ToString();
StringBuilder inSb=新的StringBuilder(id);
StringBuilder outSb=新的StringBuilder(id.Length);
字符c;
for(int i=0;i
现在,当使用查询字符串[0]
时,我只获取小数点前的值,就像我在文本框中键入的值是13.33
,那么我在列表页上只获取13
。有人能帮我吗
多谢各位 在将url发送到服务器之前,使用encodeURIComponent()对其进行编码
编辑:添加到源的链接。对参数变量使用escape,如下所示
window.showModalDialog("list.aspx?id=" + escape(param), Obj, "dialogWidth:800px; dialogHeight:500px; dialogLeft:252px; dialogTop:120px; center:yes");
或encodeURI
window.showModalDialog(encodeURI("list.aspx?id=" + param), Obj, "dialogWidth:800px; dialogHeight:500px; dialogLeft:252px; dialogTop:120px; center:yes");
调用Popup后形成的最终URL是什么?@HaseebAsif:对不起,我的错误是这一个localhost:6651/random/Page/list.aspx?id=#>>您需要对您的值进行URL编码。