this.lbParameters.Text = "Parameters: ";
        for (int i = 0; i < queryParams.Count; i++)
        {
            this.lbParameters.Text += queryParams[i].ParameterName+"  ";
        }
  
这样赋值有错吗

解决方案 »

  1.   

    没错,但是如果queryParams比较长,效率会很低,应该用StringBuilder
      

  2.   

    不长,但是我的会报运行时错误。。Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object.什么意思?
      

  3.   

      这样没错。。你把错误放到google或百度里面搜索下
      

  4.   

    queryParams是个什么类型(集合),有没有queryParams[i].ParameterName属性。
    用的Linq?
      

  5.   

    唯一的例外也可以在ASPX标记:(在“%=,或在”%#代码块)。
      

  6.   

    改改看:
    var tmpStr = "Parameters: "; 
    for (int i = 0; i < queryParams.Count; i++) 

       tmpStr  += queryParams[i].ParameterName+"  "; 

    this.lbParameters.Text = tmpStr;  另外,你这段代码是在js里面的???
      

  7.   

    引用 2 楼 mengyun221 的回复:不长,但是我的会报运行时错误。。Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object.什么意思? 改改看: 
    var tmpStr = "Parameters: "; 
    for (int i = 0; i < queryParams.Count; i++) 

      tmpStr  += queryParams[i].ParameterName+"  "; 

    this.lbParameters.Text = tmpStr;  另外,你这段代码是在js里面的???
    在cs里面的
      

  8.   

    把查询字符串中的参数的名字显示在Lable控件中:(是这个意思吧?可以参考下面的代码)
     System.Collections.Specialized.NameValueCollection coll = Request.QueryString;
             
     String[] strParamName = coll.AllKeys;
     int count = coll.Count;
     for (int i = 0; i < count; i++ )
     {
          this.lbParameters.Text += strParamName[i] + " ";             
     }
      

  9.   

    Microsoft JScript runtime error:
    报的是上面的错误,跟你这段cs代码貌似没有关系吧
      

  10.   

    不是这段代码的错误,检查下是不是使用了UpdatePanel而没有加ScriptManager。