日期:2014-05-18  浏览次数:20424 次

c#调用js中window.location.href进行页面传值??????????????大问题!郁闷...
A.aspx请求页面代码:
string suchtml="<meta content=\"China TENCENT\" name=\"TENCENT_ONLINE_PAYMENT\">\n"
+ "<script language=\"javascript\">\n"
+ "window.location.href='http://localhost/Query/B.aspx?&a=+a+&b=+b';\n"
+ "</script>";

string a = "china";
string b = "dns"
Response.Write(suchtml);

B.aspx接收显示页面代码:
Label1.Text = Request.QueryString["a"].ToString();

Label2.Text = Request.QueryString["b"].ToString();

按理论应该是没问题,但实际上是传不过去,显示的不是值.而是变量的名字a和b..

高手帮帮忙.看是不是我的url+参传值的方法不对??????

------解决方案--------------------
B.aspx?&a="+escape(a)+"&b="+escape(b)
------解决方案--------------------
Label1.Text = Server.UrlEncode(Request.QueryString["a"].ToString());
Label2.Text = Server.UrlEncode(Request.QueryString["b"].ToString());
------解决方案--------------------
获取带单引号的 url参数
要在获取页面加 <%@ Page 
 ValidateRequest="false"
------解决方案--------------------
打错了


+ "window.location.href='http://localhost/Query/B.aspx?&a=" +a+ "&b="+b+"';\n"
------解决方案--------------------
探讨
楼上的兄弟们.你们的方法都不行哈.
都抱"太多多余的字符"的错哈!

Label1.Text = Server.UrlEncode(Request.QueryString["a"].ToString());
Label2.Text = Server.UrlEncode(Request.QueryString["b"].ToString());
这个也不行哈!

------解决方案--------------------
探讨
打错了


+ "window.location.href='http://localhost/Query/B.aspx?&a=" +a+ "&b="+b+"';\n"