views:

30

answers:

2

I want to disable button when user first click it so it must not save multiple record if a user have a slow connection. Im using asp.net mvc2

+1  A: 
$('#buttonId').click(function() {
    $(this).attr('disabled', 'disabled');
});

Of course you have to adjust the selector.

Felix Kling
+2  A: 

You can use jQuery's one(). With this, the event handler is executed only once. Inside the event handler you can disable or change the style.

Example from jQuery site:

$('#foo').one('click', function() {
  alert('This will be displayed only once.');
});
Marimuthu Madasamy