Following code is not working in IE.I need to fix this in chrome,fire fox and IE
button.Attributes["disabled"] = "disabled";
Following code is not working in IE.I need to fix this in chrome,fire fox and IE
button.Attributes["disabled"] = "disabled";
You just have to set it's Enabled property to false on serverside:
button.Enabled = false;
Edit: If button is a link and it doesn't work in other browsers than IE, have a look at following link: 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>
Style for enabling and Disabling is
<style>
.LnkEnabled
{
cursor: pointer;
}
.LnkDisabled
{
cursor: default;
color: Gray;
}
</style>
javascript function
<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>
Edit2: If that doesn't work (haven't tested it), you could also try this:
button.Attributes.Add("onClick", "return !this.disabled;")
button.Attributes.Add("disabled", "true");
$('#button_id').attr('disabled', 'disabled');
Enabled=false on serverside generates or Attributes["disabled"]="disabled" does. But it apparently doesn't work for other browsers than IE with links (anchor tags): <a href="#" id="button" disabled="disabled">this is not disabled in FF</a>