Groups | Blog | Home
all groups > asp.net > august 2006 >

asp.net : Disable a button on first click


Kumar Reddi
8/5/2006 5:57:55 PM
try using the oneClick control from Metabuilders

http://www.metabuilders.com/Tools/OneClick.aspx

[quoted text, click to view]

Scott M.
8/5/2006 6:11:36 PM
Add client-side javascript: onClick="nameOfButton.enabled=false"


[quoted text, click to view]

Stuart Quinn
8/5/2006 9:13:42 PM
Is there a way to disable a button to disallow a user to click on it more
than once?

Thanks!

jmnobre
8/6/2006 12:40:33 AM
The solution maily depends on your client's browser capabilities...
If you can ensure that javascript is enabled, then you can add the
following script:

C#:
yourButton.Attributes.Add( "onClick='yourButton.enabled=false;'");

The problem is if your site is public and you cannot ensure that your
clients all have javascript enabled!
In that case, you can only rely on server side code, and you have to
ensure that if 2 posts came from the same client, all but the 1st will
be ignored!



[quoted text, click to view]
Riki
8/6/2006 11:46:33 AM
[quoted text, click to view]

If you also want to disable pressing the Enter key twice, you need
to move the script to the onSubmit event of the form.

Some of the caveats are discussed in a part of this article:
http://msdn.microsoft.com/msdnmag/issues/06/09/CuttingEdge/default.aspx#S3

--

Riki

Edwin Knoppert
8/6/2006 7:05:18 PM
I guess this.enabled = false; will do as well.
(should) save the trouble of obtaining the clientid


"Scott M." <s-mar@nospam.nospam> schreef in bericht
news:eazayuNuGHA.5056@TK2MSFTNGP06.phx.gbl...
[quoted text, click to view]

daniel NO[at]SPAM withsolutions.com
8/7/2006 11:45:54 AM
This will stop multiple submits.
I got this from this newsgroup and always
wanted to thank the author but could not locate the post..


--aspx code--
<script type="text/javascript">
var submitFlag = false;
</script>
--end code--

--Page Load code--
Submit.Attributes.Add("onclick", "javascript:if(submitFlag){return
false;}else{submitFlag=true;return true;}")
--end code--
AddThis Social Bookmark Button