asp.net 根据内容改变按钮可用不可用
<asp:Button ID="Button3" runat="server" Text="Button" Enabled="false" />
<asp:TextBox ID="TextBox1" runat="server" onkeyup="TextboxOnTextChange(this.value);"></asp:TextBox>
<script language="javascript" type="text/javascript">
// <![CDATA[
function TextboxOnTextChange(text) {
var button = document.getElementById("MainContent_Button3");
if (button == null) {
alert("Button is null");
return false;
}
if (text == "") {
button.disabled = true;
}
else {
button.disabled = false;
}
}
// ]]>
</script>