js:
   <script language="javascript">
          <!--隐藏label控件   -->
          function HideLabel() {
             document.getElementById('LabelError').style.display="none";
          }
</script>C#this.TextBoxUserName.Attributes.Add("OnTextChanged","HideLabel();");

解决方案 »

  1.   

    抱歉,上面打错了,是
    this.ButtonYes.Attributes.Add("OnClick","HideLabel();");
      

  2.   

    if( document.getElementById('LabelError').style.display=="none";
    ){
       //document.getElementById('LabelError').style.display="inline";
    }
    else
    {
       document.getElementById('LabelError').style.display="none";
    }
      

  3.   

    直接这样写不行吗?
    document.getElementById('LabelError').style.display="none";
      

  4.   

    点了按钮页面重新加载了吧,当然display:none的style就没了
      

  5.   

    应该是重新加载了,你可以跟一跟,看看 'LabelError' 的 style 属性
      

  6.   

    this.ButtonYes.Attributes.Add("OnClick","HideLabel();");
    修改为
    this.ButtonYes.Attributes.Add("OnClick","HideLabel();return(false);");原来的写法,页面将提交,提交之后,以脚本实现控件隐藏将失效。