我有两个控件分别是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>
<asp:TextBox ID="address" Runat="server" enabled="false" width="500" MaxLength="100" ></asp:TextBox><script language="">
......什么
</script>
<script>
function changeTextbox(cb)
{
var tb = document.getElementById("address");
if(tb)
{
tb.disabled = !cb.checked;
}
}
</script>后台:
picture.InputAttributes.Add("onclick", "changeTextbox(this);");