日期:2014-05-20  浏览次数:20496 次

关于超链接传多个参数,总是出问题
代码如下
xxx1.aspx的转向是这么写的
Response.Redirect( "xxx2.aspx?   name= "+name+ "   &   time1= "+worktime+ " ");
xxx2.aspx接参数是这样写的
name   =   Request.Params[ "name "].ToString();
time   =   Request.Params[ "time1 "].ToString();
我在xxx1.aspx里测试过两个参数都有值,但为什么在xxx2.aspx里接参数接到time1参数时就报未设置对象引用,而光传name参数却不报错,我想了好半天没有想通,因为我用forreach循环接就接出来了,代码如下
foreach(string   key   in   Request.Params.Keys)
{
Response.Write(key+   "   =   "   +   Request.Params[key].ToString()+   " <br> ");
if(key   ==   "name ")
{
name   =   Request.Params[ "name "].ToString();
}
if(key   ==   "time1 ")
{
time   =   Request.Params[ "time1 "].ToString();
}
}
就没有报错,那位大虾告诉我为什么啊,谢谢

------解决方案--------------------
难道是空格的原因?

建议这么写:
Response.Redirect(string.Format( "{0}?name={1}&time1={2} ", "xxx2.aspx ", name, worktime));