用ID呀!getElementById("Guestbook1_ipt_name"').value
为了得到正确的客户端ID你可以在服务器端产生js脚本到客户端!可以使用下面的方法得到
this.YourControl.UniqueID.Replace(":","$")将:替换成$或者替换成_都可以!

解决方案 »

  1.   

    不是用户控件的问题,这是asp.net控件的命名机制决定的,用Javascript获取的应该是控件的ID,而不是name,ID是优先于name属性的。
      

  2.   

    only if your control is a server control<asp:TextBox id="ipt_name" runat="server" />
    try to output the id to the client side, for exampledocument.getElementById("<%=ipt_name.ClientID%>").valueordocument.forms[0].elements["<%=ipt_name.UniqueID%>"].valueor go through the elements collectionfor (var i=0; i < document.forms[0].elements.length; i++)
    {
      if (document.forms[0].elements.name.indexOf("ipt_name") >= 0)
      {
        //you got your control
      }
    }
      

  3.   

    for (var i=0; i < document.forms[0].elements.length; i++)
    {
      if (document.forms[0].elements.name.indexOf("ipt_name") >= 0)
      {
        //you got your control
      }
    }
      

  4.   

    应使用ID进行访问
    ID和NAME最好保持一致
      

  5.   

    应该用ID取值,如下:var strValue = document.getElementById("Guestbook1_ipt_name"').value;ID优先于Name,为了清楚起见,建议ID和NAME保持一致!