Disable button to prevent double clicking

  • Thread starter Thread starter Buddy Ackerman
  • Start date Start date
B

Buddy Ackerman

If I put client side code to disable a button (so that a user doesn't click
it twice and double post the form) then teh button doesn't get posted with
the form and the button's server-side click event handler is not fired.
Seems like a big hole in the ASP.NET form handling process. Any way around
it and still use the button click event handler?


--Buddy
 
Hi,

You can keep a image and the button in the same div tag. Initially, make the
button visible and the image invisible. And when the user clicks the button
then hide the button and make the image visible. So in this situation user
will not be able to click the button twice and your problem will get solved.

Regards,
Parag Kulkarni
MTS | Persistent Systems Private Limited
 
Buddy,

I built a javascript component that I give away for free (with source code).
One of the scripts in the component does exactly what you're attempting
here. You can see a sample and download the code from here:
http://www.aboutfortunate.com?page=javascriptdemo. You'll be interested in
demo# 3.

One thing that the code does is to call .NET's own javascript for checking
page validity before disabling the button. That way if a form isn't valid
the button doesn't get disabled which would strand the user.

If you have any questions let me know. The code is currently written for
..net 1.1 but is easily upgraded. If you're using 2.0 and have any difficulty
upgrading the code yourself let me know and I'll give you a hand. I just
haven't gotten around to posting updated code to my site yet.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
<INPUT id="myButton" onclick="document.form1.myButton.disabled=true;"
type="button" value="Submit" name="myButton" runat="server"
onserverclick="myButton_Click">

The button will disable itself on click, and run the sub of your
choice.

Hope it helps,
Jeremy Reid
http://hgtit.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top