嗨朋友我有一个按钮控件,必须启用基于我的asp.net复选框检查,但是当运行代码时我面临的问题我的按钮仍然被禁用,即使我执行复选框检查.is他们的任何属性,我已设置在代码后面,以检查事件。基于asp.net复选框启用和禁用按钮控制的问题检查
我用我的应用程序 下面的代码这是我的JavaScript文件
<script type="text/javascript">
function theChecker() {
var checkboxId = '<%= SpEligible.ClientID %>';
alert(checkboxId);
if (checkboxId.checked == true)
{
document.getElementById("SplistButton").disabled = false;
}
else
{
document.getElementById("SplistButton").disabled = true;
}
}
</script>
这是我的复选框代码和按钮
<asp:CheckBox ID="SpEligible" runat="server" Text="SpEligible" class="cBox" />
<asp:Button ID="SplistButton" runat="server" OnClientClick=" return ShowInsertForm()" Enabled="false"/>
这是我的aspx.cs文件我打电话给的那个javascript
SpEligible.Attributes.Add("onclick", "theChecker()");
非常感谢,我的代码现在工作正常 – mahesh