以下代码在IE中不起作用.我需要在chrome,fire fox和IE中修复此问题
button.Attributes["disabled"] = "disabled";
Run Code Online (Sandbox Code Playgroud)
您只需将其Enabled属性设置为false在服务器端:
button.Enabled = false;
Run Code Online (Sandbox Code Playgroud)
编辑:如果button是一个链接,它不能在IE以外的其他浏览器中工作,请查看以下链接:http://www.aspnetajaxtutorials.com/2009/05/how-to-enable-or-disable-linkbutton -in.html
<asp:LinkButton ID="lnkTest" runat="server" CommandArgument="1" CommandName="1x"
OnClick="lnkTest_Click">Test</asp:LinkButton>
Run Code Online (Sandbox Code Playgroud)
启用和禁用的样式是
<style>
.LnkEnabled
{
cursor: pointer;
}
.LnkDisabled
{
cursor: default;
color: Gray;
}
</style>
Run Code Online (Sandbox Code Playgroud)
javascript函数
<script language="javascript">
function EnableLinkButton(ID,flag)
{
document.getElementById(ID).onclick=function(){return flag;};
if(!flag)
{
document.getElementById(ID).setAttribute("disabled","disabled");
document.getElementById(ID).className="LnkDisabled";
}
else
{
document.getElementById(ID).setAttribute("disabled","");
document.getElementById(ID).className="LnkEnabled";
}
}
EnableLinkButton('<%= lnkTest.ClientID %>',false);
</script>
Run Code Online (Sandbox Code Playgroud)
编辑2:如果这不起作用(尚未测试),你也可以试试这个:
button.Attributes.Add("onClick", "return !this.disabled;")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1836 次 |
| 最近记录: |