Click here to Skip to main content
Licence CPOL
First Posted 6 Feb 2008
Views 11,306
Bookmarked 13 times

How to do a click once button in AJAX

By | 7 Feb 2008 | Article
A click once button.

Introduction

This code makes a button clickable only once.

Background

I did a page with an UpdatePanel on it.

Since I had a lot of controls between the order button (BESTÄLL) and the panel, I did the order button external to the panel.

I needed the order button clickable only once, in order to achieve this:

Two.JPG

Using the Code

I added an onSubmit method to the form:

<form id="form1" runat="server" 
  onsubmit="document.form1.btnOrder.disabled = true;return true;"> 
...
<button id="btnOrder" style="MARGIN-LEFT: 20%" 
  runat="server" text="BESTÄLL"></button>

Points of Interest

The key to make it work is:

return true;

Otherwise, the server side event doesn't trigger.

Comments

I would appreciate feedback and tips on a more .NET-tish way of doing this.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Michael Rosqvist

Web Developer

Sweden Sweden

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
General[My vote of 1] Not working PinmemberVuyiswa Maseko3:46 20 Aug '09  
GeneralUse an extender, create a behavior Pinmemberalexgoodbox17:49 7 Feb '08  
GeneralOr Else Pinmemberdjsolid2:04 7 Feb '08  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 7 Feb 2008
Article Copyright 2008 by Michael Rosqvist
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid