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>

posted @ 2011-02-21 10:33  Mo  阅读(935)  评论(0编辑  收藏  举报