Limiting User Clicks

E

Elroyskimms

This may sound like a stupid question. Perhaps there is a simple answer
that I am overlooking.

I need some method of preventing the user from clicking the submit
button multiple times that is supported across various browser
platforms. I've tried everything I can think short of a wi-fi enabled
electric shock collar for stupid user training.

DETAILS:
I have a web application that processes information submitted via a
form. The entire process takes a couple of seconds, and no matter how
many times I tell the user to "only click the submit button once", at
least 10% of the users still double-click the button because they don't
know the difference between a desktop icon and a web button. Or, they
are impatient and can't wait the 3 or 4 seconds it takes for the
processing to complete.
 
M

Milsnips

why dont you put an Onclick event on the button and change button to
disabled (via javascript) and maybe the text of the button to "please
wait..." ?

regards,
Paul
 
E

Elroyskimms

Using server side scripting, the postback takes too long to prevent the
user from "double clicking" the button, like they do a Windows icon.

I read somewhere that client side Javascript usedto disable a button
only works in IE. Is that true?
 
K

Kevin Spencer

Disabling any type of client-side intrinsic functionality is generally a bad
idea, not to mention an exercise in futility. Handling it is much better.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.
 
E

Eitan

I hope the following code will help.

In page_load event do :

(btnNew is the related button).
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim btn As HtmlInputButton;

btn = CType(btnNew, HtmlInputButton)

btn.Attributes.Add("onclick", _

String.Format("domyfunc();"))

If (Not IsPostBack) Then

....

end if

end sub


and in the html code of aspx :

....
<script>

function domyfunc()
{ var btn;
btn = document.getElementById("btnNew");
btn.disabled = true; // remember this line, that users could not click
twice on the button very fast.
alert("do something"); // do something of your own
btn.disabled = false; // remember this line
}

</script>

....
Know that every ASPx is basically HTML (but not vice versa).
Think that ASPx writes always the code behind.
When - when doing page_load.

The sample is on page load (before clicking any button), so time here is no
consuming (the event was calculated before you even see the page on the
client).

I am newbie in .NET, and I am asking this newsgroup also,
but I think this code is fine ,after I tested it.

Cheers :)
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top