<script language="javascript">
  
          function HideLabel() {
             document.getElementById('LabelError').style.display="none";
          }
</script>上面是js代码
下面是定义:<SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 黑体"><font color="white">用户名:<asp:TextBox id="TextBoxUserName" runat="server" Width="108px" BorderStyle="None" Height="23px"
OnTextChanged="HideLabel()"></asp:TextBox></font></SPAN>请问错在什么地方?多谢!

解决方案 »

  1.   

    TextBox是在服务器上运行的,所以它的OnTextChanged事件不能用javascript来写,必须用C#之类的服务器语言来写。
      

  2.   

    隐藏一个Lable控件,只需把它的Visible属性置为False即可
      

  3.   

    OnTextChanged="HideLabel()"错误出在这里,不能用OnTextChanged
    改为
    //html代码
    <script language="javascript">   
    function HideLabel()
    {
           document.getElementById('LabelError').style.display="none";
    }
    </script><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 黑体"><font color="white">用户名:<asp:TextBox id="TextBoxUserName" runat="server" Width="108px" BorderStyle="None" Height="23px"></asp:TextBox></font></SPAN>
    //后台cs代码
    private void Page_Load(object sender, System.EventArgs e)
    {
    this.TextBoxUserName.Attributes.Add("onchange","HideLabel();");
    }
      

  4.   

    服务器控件的事件触发要在cs里面写
    this.Control.Attributes.Add(......);