Click Once For LinkButton Not Working

X

xenophon

I am trying to add "click once" functionality to my ASP.NET page. I
have this attribute in my form tag:

onsubmit="return SubmitCheck()"


And I have the below in my <head> tag, but for some reason the click
never gets intercepted. What am I doing wrong?


<script language='javascript' type='text/javascript'>
<!--
function window_onload()
{
var __oldPostBack = __doPostBack;
__doPostBack = SubmitCheck;
}
// -->
</script>
<script language='javascript' type='text/javascript'>
<!--
var submitCount=0;
function SubmitCheck( eventTarget , eventArg )
{
if (submitCount == 0)
{
submitCount++;
return __oldPostBack(eventTarget , eventArg);
}
else
{
alert( submitCount + 'Please wait.');
}
}
// -->
</script>









Thanks.
 
B

bruce barker

1) the onsubmit event won't fire for a linkbutton, only for submit buttons
or the enter key.
2) you don't show where you window_onload() routine is called, so probably
it isn't

-- bruce (sqlwork.com)


|
| I am trying to add "click once" functionality to my ASP.NET page. I
| have this attribute in my form tag:
|
| onsubmit="return SubmitCheck()"
|
|
| And I have the below in my <head> tag, but for some reason the click
| never gets intercepted. What am I doing wrong?
|
|
| <script language='javascript' type='text/javascript'>
| <!--
| function window_onload()
| {
| var __oldPostBack = __doPostBack;
| __doPostBack = SubmitCheck;
| }
| // -->
| </script>
| <script language='javascript' type='text/javascript'>
| <!--
| var submitCount=0;
| function SubmitCheck( eventTarget , eventArg )
| {
| if (submitCount == 0)
| {
| submitCount++;
| return __oldPostBack(eventTarget , eventArg);
| }
| else
| {
| alert( submitCount + 'Please wait.');
| }
| }
| // -->
| </script>
|
|
|
|
|
|
|
|
|
| Thanks.
|
|
 
S

Steven Cheng[MSFT]

Hi Xenophon,

I think Bruce's suggestion is reasonable ,the onsubmit won't be fire by all
the post back enabled controls. Instead of using the onsubmit event or
intercept the __doPostBack function, I think you can also consider just
disable the certain submit button after the user first time click it. Also,
the end user still can refresh the page to make multi post back submits. So
it is most important to also provide serverside transaction checking or
even in database level. Here are some tech articles and former threads
discussing on the similiar problem:

#How to prevent multiple clicks of a submit button in ASP.NET
http://aspzone.com/articles/207.aspx

http://groups-beta.google.com/group/microsoft.public.dotnet.framework.aspnet
/browse_thread/thread/7743c065b33c241d/33c3f7f4cc5f79a5?q=asp.net+prevent+pa
ge+multiple+submit&_done=%2Fgroups%3Fhl%3Den%26lr%3D%26q%3Dasp.net+prevent+p
age+multiple+submit%26&_doneTitle=Back+to+Search&&d#33c3f7f4cc5f79a5

http://groups-beta.google.com/group/microsoft.public.dotnet.framework.aspnet
/browse_thread/thread/6fab6a8261900df3/2d7bf741ea8c2024?q=asp.net+prevent+pa
ge+multiple+submit&_done=%2Fgroups%3Fhl%3Den%26lr%3D%26q%3Dasp.net+prevent+p
age+multiple+submit%26&_doneTitle=Back+to+Search&&d#2d7bf741ea8c2024


HTH.

Thanks & Regards,

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

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,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top