2

We are using jquery-1.7.1 and are trying to hide a button in asp.net. The button is a linkbutton control. The code we are using is as follows

function checkDisabledButton(btn){
    var mbtn = $('#' + btn)
    mbtn.prop('disabled', true);
};

the button gets disabled in IE but Chrome and Firefox is does not get disabled. I've seen a lot of post about it.. but most of those talk about needing jQuery 1.7.. which we are already using. Was hoping someone could lend a hand.

After looking at the reponses I've been looking into changing to a asp:button which gets rendered as an input type=submit. What i really want is to be able to call a function to do the disable of the control. In that way i can use the same function for multipal buttons and multipal pages. I've still not got it working, but with that in mind.. I was hoping someone could continue with the help. Here is the button control being called

<asp:Button ID="lbApprove" runat="server" CssClass="ButtonPrimary button" Text="Approve" OnClientClick="return tryIt(this, 'PROCESSING');"/>

The tryIt changes the text of the button once clicked to whatever i pass in (in this case 'PROCESSING'). Again.. i want the button to only be clickable once. I've looked at the .one and also the .on and .off but haven't had any luck just yet. I am not posting any code at this point as it's just try's so far...

Here is the latest and at first attempt appears to work. It's not jQuery.. but might be a start. It disables the button before page postback happens. It comes from this article. Got to have a starting point right :)

http://aspsnippets.com/Articles/Disable-Button-before-Page-PostBack-in-ASP.Net.aspx

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
jvcoach23
  • 2,765
  • 10
  • 34
  • 50

1 Answers1

3

If it's a link button, then it renders as an anchor. The disabled attribute isn't a standard attribute for anchors. The fact that IE works is nonstandard/unspecified behavior.

As proof, see this jsfiddle where I'm setting disabled not through jquery but through the html attribute http://jsfiddle.net/5htFh/. Note in FF it still follows. So it's not jquery failing you in anyway; it's the fact that disabled just isn't an option for anchors under the html4 spec.

See this SO thread on how others recommend doing this with anchors: How to enable or disable an anchor using jQuery?

Community
  • 1
  • 1
Eli Gassert
  • 9,745
  • 3
  • 30
  • 39