![]() |
Click Once For LinkButton Not Working
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. |
Re: Click Once For LinkButton Not Working
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) "xenophon" <xenophon@online.nospam> wrote in message news:j0elv05kc7ui5n7uga7nctmkicqrc3bth2@4ax.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. | | |
Re: Click Once For LinkButton Not Working
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/...amework.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/...amework.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.) |
| All times are GMT. The time now is 04:23 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.