468,253 Members | 1,302 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,253 developers. It's quick & easy.

Disable button to prevent double clicking

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
Feb 27 '06 #1
4 8683
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 Ackerman" <bu**********@buddyackerman.com> wrote in message
news:e9*************@TK2MSFTNGP11.phx.gbl...
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

Feb 27 '06 #2
Post you client-side event handler.

Eliyahu

"Buddy Ackerman" <bu**********@buddyackerman.com> wrote in message
news:e9*************@TK2MSFTNGP11.phx.gbl...
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

Feb 27 '06 #3
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
"Buddy Ackerman" <bu**********@buddyackerman.com> wrote in message
news:e9*************@TK2MSFTNGP11.phx.gbl...
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

Feb 27 '06 #4
<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

Feb 28 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Jason | last post: by
1 post views Thread by Aubyone | last post: by
reply views Thread by Michiel Rapati-Kekkonen | last post: by
2 posts views Thread by Tom | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.