0

Following code is not working in IE.I need to fix this in chrome,fire fox and IE

 button.Attributes["disabled"] = "disabled";
3
  • 2
    you do it in javaScript or on server side? Commented Aug 28, 2012 at 11:45
  • What is the generated html source code of this object? Commented Aug 28, 2012 at 11:46
  • For what? as @harry180 said it shell be better to make it with js Commented Aug 28, 2012 at 11:47

3 Answers 3

6

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;")
Sign up to request clarification or add additional context in comments.

Comments

1
 button.Attributes.Add("disabled", "true"); 

1 Comment

Ohk..try now..I have made some changes.
0
$('#button_id').attr('disabled', 'disabled');

1 Comment

Is the same as what 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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.