日期:2014-05-17  浏览次数:20619 次

JS参数问题。int的可以,换成string就不行了。急求解答,在线等
在下在做对父评论就行回复。在<a href="">回复</a>处的参数赋值时出了问题。五个参数也不知什么情况,给了string的就不会进reply方法。在别的类似的类里,有个类似的js方法,四个参数都是string的,是可以用的。但是拿到这边来,给string参数就不好使了。虚心求教.
C# code


  public  commentBO(int weiboid, int page)
       {
           Content = "";
           string linkhtml = string.Empty;
           int pgCount = 1;
           dt = cs.GetAllComments(weiboid,page);

           for (int i = 0; i < dt.Rows.Count; i++)
           {
               
               string fatherid = dt.Rows[i][1].ToString();
               users = us.GetUserByUserid(Convert.ToInt32(dt.Rows[i][5]));
               string photo = "Upload/" + users.Photo;
               string Cname = users.Username;
               int aaa = 33;
               string time =dt.Rows[i][3].ToString();
               string commentContent = dt.Rows[i][6].ToString();
               Content += "<div class=\"codivcontent\">";
               Content += "<div class=\"cocontent\">";
               Content += "<div class=\"codivimg\">";
               Content += "<img src=\""+photo+"\" width=\"35px\"/>";//头像
               Content += "</div>";
               Content += "<div class=\"codivtxt\">";
               Content += "<a href=\"javascript:void(0)\">" + Cname + "</a>:";//////姓名
               Content += "<a href=\"javascript:void(0)\">";
               Content += "<em class=\"commentem\">" + commentContent + "(" + time + ")</em>";///////评论内容
               Content += "</a>";
               Content += "</div>";
               Content += "</div>";
               Content += "<div class=\"commentreply\">";
  /////////////////问题部分。
             Content += "<a href=\"javascript:void(0)\" onclick=\"reply(" + fatherid + ",$(this).parent().parent().parent().parent().attr('id')," + weiboid + ",333,$(this).parent().parent().parent().attr('id'))\">";
                /////////////////问题部分。在给reply参数赋值的时候,第四个参数也就是'333'那儿,int 类型的都可以,但是只要改成string的就不行了。我试过另一个类似的类里可以用的js方法,到这里之后就不可以了,参数类型都是一样的。
               Content += "回复</a>";
               Content += "</div>";
               Content += "</div>";
               
           }

           int rescount = cs.GetCount(weiboid);
           Content += "<div class=\"pages\">已有" + rescount + "条评论&nbsp;{$link_list$}</div>";
           pgCount = (rescount / pagesize) + 1;


           if (pgCount > 1)
           {
               for (int j = 0; j < pgCount; j++)
               {
                   int pagenum = j + 1;
                   linkhtml = linkhtml + ((j == page) ? "<span class=\"current\">" + pagenum + "</span>&nbsp;" : "<a href=\"javascript:void(0)\" onclick=\"getcomment(" + weiboid + "," + j + ",$(this).parent().parent().attr('id'))\">" + pagenum + "</a>&nbsp;");

               }

           }
           else
           {
               linkhtml = "";
           }

           Content = Content.Replace("{$link_list$}", linkhtml);    
       
       }






这是前台的JS方法

JScript code


 function reply(fatherid, fatherdiv, weiboid, username, allcomme