请问:
   怎么样把控件名称当作参数发送到javascript中?我的写法如下:
    ImageButton1.Attributes.Add("onClick", "return calendar(document.getElementById(\"<%=TextBox1.ClientID%>\"));");
   是写在page_load事件中的,但是javascript中得到的仍然是空值。请各位赐教!

解决方案 »

  1.   

    为什么不在js里面直接用TextBox1呢?
      

  2.   

    document.getElementById('"+TextBox1.ClientID+"')
    这种问题,最好就是浏览查看源代码,就会发现问题
      

  3.   

    ImageButton1.Attributes.Add("onClick", "return calendar(event.srcElement.id);"); 
      

  4.   

    event.srcElement不支持ff,还是像2楼说的,看看html源,判断错误原因吧
      

  5.   

    ImageButton1.Attributes.Add("onClick", "return calendar(document.getElementById(\" " + TextBox1.ClientID + "\"));"); 
      

  6.   

    客户中直接写即可document.getElementById("<%=TextBox1.ClientID%>"); 
      

  7.   

    string str = "return calendar(document.getElementById('{0}'))";
    ImageButton1.Attributes.Add("onClick", string.Format(str,TextBox1.ClientID));
      

  8.   

    直接把控件ID作为参数就可以了
    ImageButton1.Attributes.Add("onClick", "return calendar(TextBox1.ClientID));"); 
      

  9.   

    ImageButton1.Attributes.Add("onClick", "return calendar(TextBox1));"); 
      

  10.   


    document.getElementById("<%=TextBox1.ClientID%>"); 这样不是更好