我有两个控件分别是Checkbox和TextBox,想要实现的功能是页面载入时,Textbox不能使用,只有当CheckBox被选择时才能使用.下面是两个控件的代码:<asp:CheckBox ID="picture" Runat="server" Text="图片新闻"></asp:CheckBox>
<asp:TextBox ID="address" Runat="server" enabled="false" width="500" MaxLength="100" ></asp:TextBox><script language="">
......什么
</script>

解决方案 »

  1.   

    前台:
    <script>
      function changeTextbox(cb)
      {
        var tb = document.getElementById("address");
        if(tb)
        {
            tb.disabled = !cb.checked;
         }
      }
    </script>后台:
    picture.InputAttributes.Add("onclick", "changeTextbox(this);");
      

  2.   

    picture.Attributes["onclick"] = string.Format("document.getElementById(\"{0}\").disabled = !this.checked",address.ClientID);
      

  3.   

    babyrockxray(Game~Over)请问一下,后台的代码是必须的吗?我只用了前台的代码不过好象不可以啊
      

  4.   

    不能直接获取address吧?好象应该是获取address.clientID吧?