ASP.NET Button – prevent double clicks part 2

by Mark Wiseman on June 2nd, 2010 | Posted in Revium Sandbox | Read the comments

It is amazing how may people out there still apply the double click paradigm to web applications.

What is frustrating is that some of the most simple methods for preventing the double click stop ASP.Net from firing the appropriate click event when the page is posted back.

A while ago Evgeny posted an article on how to prevent double clicks on buttons in ASP.Net. This solution was a little code heavy for my liking and so after a bit of playing around i came up with this simple jQuery solution.

That is where this little jQuery script come in. When the user clicks an input with the class of ‘button’ we will apply an attribute to it so that the next time the user clicks it, the event wont fire again. Easy!

$(document).ready(function () {
    //prevent double clicks
    $(".button").click(function () {
        if ($(this).attr("dblclick") != "true")
            $(this).attr("dblclick", "true");
        else
            return false;
    });
});

Related posts:

  1. ASP.NET Button – prevent double clicks
  2. jQuery image captions
  3. “Capitalise” jquery extension
  4. ASP.NET selectors in jquery
  5. Kentico 6.0 Custom BizForm Validation

Tags: asp.net, jquery

« The easy way to clear floated elements

Linq – SubmitChanges does not work »

3 Responses to “ASP.NET Button – prevent double clicks part 2”

  1. anotherarc says:
    December 10, 2010 at 11:10 pm

    A bit simpler:

    $(document).ready(function(){
    $(‘.oncebutton’).one(‘click’, function() {
    $(this).slideUp();
    });
    });

  2. Doug says:
    December 5, 2012 at 8:09 am

    Unfortunately this solution does not take into account postbacks or page validation.

  3. Mark Wiseman says:
    December 17, 2012 at 4:34 pm

    Thanks Doug. This was just a simple example on how to prevent the double click.
    You could easily add the validation call within here and if there are no issues then prevent a second click.

Leave a Reply

Click here to cancel reply.

Recent Articles

  • ISAF Sailing World Cup
  • Revium Supports the Prostate Cancer Foundation of Australia
  • Kentico FAQ Module
  • Advanced Visitor Tracking in Analytics
  • Kentico, Smart Search and filtering attachments
  • Enhancing JIRA’s Issue Navigator
  • Mobile Browsing
  • Revium help win gold for Australia

Twitter

  • All things Gold! http://t.co/9DkkjmAr 2012-09-13
  • Mat Belcher - our favourite London Gold Medalist dropped into the office to say thank you. http://t.co/TxHbe2y6 2012-09-13
  • You beauty - http://t.co/1kbcBZwg #london2012 @belcherpage2012 2012-08-10
  • More updates...

Revium Logo

  • Home
  • About
  • Expertise
  • Showcase
  • Contact

  • news
  • blog
  • sandbox
  • twitter
  • rss
  • visit our facebook page

We are Revium, hear us roar!

The news.

26 Feb

Revium Supports the Prostate Cancer Foundation of Australia

We here at Revium are proud to say that we are supporting the Prostate Cancer Foundation of Australia, this month we have been able…

Continue reading
View archive

The blog.

11 Apr

ISAF Sailing World Cup

Mat Belcher and his team have been successful in taking out round 3 of the ISAF Sailing World Cup in Palma de Mallorca a…

Continue reading
View archive

The sandbox.

20 Dec

Kentico, Smart Search and filtering attachments

We had a scenario recently where we had 2 indexes set up in Kentico to search different folders within our site. Everything worked as…

Continue reading
View archive

eNewsletter.

 

© Copyright 2013. All Rights Reserved.

Revium Pty Ltd

info@revium.com.au Work +61 3 9429 2000

10 Harvey Street
Richmond, Victoria, 3121 Australia
View map

Disclaimer and privacy Revium Pty Ltd

Find us: web development, seo

 
Partner logos