html code:
<asp:Button runat="server" ID="btnTest" Text="Test" OnClick="btnTest_Click" />
Jquery Code:
$('[id$=btnTest]').click(function(){
   $('[id$=btnTest]').attr('disabled', 'true');
});
CodeBehind:
protected void btnTest_Click(object sender, EventArgs e)
{
//here not come.
}
Code Behind btnTest event not work ?
I think that making the button disabled in the click event handler is preventing the postback. Try executing the disabling code after some time:
$('[id$=btnTest]').click(function(){
    var button = this;   
    setTimeout(function() {
        $(button).attr('disabled', 'disabled');
    }, 100);
});
                        Try to use jQuery class selector:
CssClass="MyButton" to your ASP.NET button;disabled="disabled" attribute on clickjQuery:
$('button.MyButton').click(function(){ 
  $(this).attr('disabled', 'disabled');
});
                        The sample code is using the ends-with selector. There is no mistake in selector. you just need to change the code like this
$('[id$=btnTest]').click(function () {
       $('[id$=btnTest]').attr('disabled', true);
});
I have tested this and works fine without any issues.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With