我知道这可能是一个简单的修复,但我似乎无法弄清楚这里的问题......
我试图在单击 RadioButton1 时禁用 insidethepast 文本框。
<asp:RadioButton ID="RadioButton1" runat="server" Checked="True" GroupName="DateTimeQuery" OnClick="javascript:TimeRangeClickEvent()"/>
<asp:TextBox ID="withinthepast" runat="server" Text="1"></asp:TextBox>
<script>
function TimeRangeClickEvent()
{
var radio1 = document.getElementById('<%=RadioButton1.ClientID%>').checked;
if (radio1 == true)
{
var within = document.getElementById('<%=withinthepast.ClientID%>').enabled = false;
}
}
</script>
有什么建议吗?
最佳答案
问题可能出在“enabled”属性上。你可以试试这个:
启用控件:ctl.removeAttribute("disabled")
要禁用控件:ctl.setAttribute("disabled", "disabled")
关于javascript - 使用 javascript 的 ASP.NET 控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35631724/