Click here to Skip to main content
13,198,482 members (63,424 online)
Click here to Skip to main content
Add your own
alternative version


13 bookmarked
Posted 6 Feb 2008

How to do a click once button in AJAX

, 7 Feb 2008
Rate this:
Please Sign up or sign in to vote.
A click once button.


This code makes a button clickable only once.


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:


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.


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


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
No Biography provided

You may also be interested in...

Comments and Discussions

General[My vote of 1] Not working Pin
Vuyiswa Maseko20-Aug-09 3:46
memberVuyiswa Maseko20-Aug-09 3:46 
GeneralUse an extender, create a behavior Pin
alexgoodbox7-Feb-08 17:49
memberalexgoodbox7-Feb-08 17:49 
GeneralOr Else Pin
djsolid7-Feb-08 2:04
memberdjsolid7-Feb-08 2:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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 | Terms of Use | Mobile
Web03 | 2.8.171020.1 | Last Updated 7 Feb 2008
Article Copyright 2008 by Michael Rosqvist
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid