Call this function from the Page_OnLoad event of your asp.net page.
This will prevent the user from doing multiple post backs or button
clicks.
This was designed to not disable the button, because asp.net 1.x will
not pick up the button click event.
Instead, it monitors the on submit event of the form and the
_doPostBack event of the asp.net page.
It overrides the _doPostBack and onsubmit events and checks whether
the page has already been submitted or posted back.
If the user does anything during a submit or postback, it is ignored.
The code below is using a submit button named "btnNext"; you can
change the code to reference your own button.
============Beg in Code=========== =======
Public Function PutOnSubmitButt onDisabler(ByRe f oPage As Page)
If Not oPage.IsClientS criptBlockRegis tered("PleaseWa it") Then
oPage.RegisterC lientScriptBloc k("PleaseWait ", "<script
type='text/javascript'>" & vbCrLf & _
"var PageIsProcessin g = false;" & vbCrLf & _
"function PleaseWait(){" & vbCrLf & _
"if(Page_IsVali d){" & vbCrLf & _
"if(PageIsProce ssing==true){" & vbCrLf & _
"return false;" & vbCrLf & _
"}else{" & vbCrLf & _
"if(document.fo rms[0].btnNext !=
null){document. forms[0].btnNext.value = 'Processing...' ;}" & vbCrLf &
_
"PageIsProcessi ng = true;" & vbCrLf & _
"return true;" & vbCrLf & _
"}" & vbCrLf & _
"}" & vbCrLf & _
"}" & vbCrLf & _
"</script>")
End If
oPage.RegisterS tartupScript("P leaseWaitOnPost Back", "<script
type='text/javascript'>" & vbCrLf & _
"var __doPostBack__ = window.__doPost Back;" & vbCrLf & _
"window.__doPos tBack = function(eventT arget, eventArgument) {" &
vbCrLf & _
"if(PageIsProce ssing==true){" & vbCrLf & _
"}else{" & vbCrLf & _
"if(document.fo rms[0].btnNext !=
null){document. forms[0].btnNext.value = 'Processing...' ;}" & vbCrLf &
_
"__doPostBack__ (eventTarget, eventArgument); " & vbCrLf & _
"PageIsProcessi ng = true;" & vbCrLf & _
"}" & vbCrLf & _
"}" & vbCrLf & _
"</script>")
oPage.RegisterO nSubmitStatemen t("PleaseWait ",
"if(!PleaseWait ()){return false};")
End Function
============End Code=========== ======= 2 8926
This assumes the browser has javascript enabled. How do you prevent multiple
submits in a purely server side way with .net?
"Ghafran Abbas" wrote: Call this function from the Page_OnLoad event of your asp.net page. This will prevent the user from doing multiple post backs or button clicks. This was designed to not disable the button, because asp.net 1.x will not pick up the button click event. Instead, it monitors the on submit event of the form and the _doPostBack event of the asp.net page. It overrides the _doPostBack and onsubmit events and checks whether the page has already been submitted or posted back. If the user does anything during a submit or postback, it is ignored.
The code below is using a submit button named "btnNext"; you can change the code to reference your own button.
============Beg in Code=========== =======
Public Function PutOnSubmitButt onDisabler(ByRe f oPage As Page)
If Not oPage.IsClientS criptBlockRegis tered("PleaseWa it") Then oPage.RegisterC lientScriptBloc k("PleaseWait ", "<script type='text/javascript'>" & vbCrLf & _ "var PageIsProcessin g = false;" & vbCrLf & _ "function PleaseWait(){" & vbCrLf & _ "if(Page_IsVali d){" & vbCrLf & _ "if(PageIsProce ssing==true){" & vbCrLf & _ "return false;" & vbCrLf & _ "}else{" & vbCrLf & _ "if(document.fo rms[0].btnNext != null){document. forms[0].btnNext.value = 'Processing...' ;}" & vbCrLf & _ "PageIsProcessi ng = true;" & vbCrLf & _ "return true;" & vbCrLf & _ "}" & vbCrLf & _ "}" & vbCrLf & _ "}" & vbCrLf & _ "</script>") End If
oPage.RegisterS tartupScript("P leaseWaitOnPost Back", "<script type='text/javascript'>" & vbCrLf & _ "var __doPostBack__ = window.__doPost Back;" & vbCrLf & _ "window.__doPos tBack = function(eventT arget, eventArgument) {" & vbCrLf & _ "if(PageIsProce ssing==true){" & vbCrLf & _ "}else{" & vbCrLf & _ "if(document.fo rms[0].btnNext != null){document. forms[0].btnNext.value = 'Processing...' ;}" & vbCrLf & _ "__doPostBack__ (eventTarget, eventArgument); " & vbCrLf & _ "PageIsProcessi ng = true;" & vbCrLf & _ "}" & vbCrLf & _ "}" & vbCrLf & _ "</script>") oPage.RegisterO nSubmitStatemen t("PleaseWait ", "if(!PleaseWait ()){return false};") End Function
============End Code=========== =======
You can use a variable in the user's session: http://www.daveandal.net/books/6744/...one-click.aspx
"Stephen J. Kladich" <St************ *@discussions.m icrosoft.com> wrote in
message news:F2******** *************** ***********@mic rosoft.com... This assumes the browser has javascript enabled. How do you prevent
multiple submits in a purely server side way with .net?
"Ghafran Abbas" wrote:
Call this function from the Page_OnLoad event of your asp.net page. This will prevent the user from doing multiple post backs or button clicks. This was designed to not disable the button, because asp.net 1.x will not pick up the button click event. Instead, it monitors the on submit event of the form and the _doPostBack event of the asp.net page. It overrides the _doPostBack and onsubmit events and checks whether the page has already been submitted or posted back. If the user does anything during a submit or postback, it is ignored.
The code below is using a submit button named "btnNext"; you can change the code to reference your own button.
============Beg in Code=========== =======
Public Function PutOnSubmitButt onDisabler(ByRe f oPage As Page)
If Not oPage.IsClientS criptBlockRegis tered("PleaseWa it") Then oPage.RegisterC lientScriptBloc k("PleaseWait ", "<script type='text/javascript'>" & vbCrLf & _ "var PageIsProcessin g = false;" & vbCrLf & _ "function PleaseWait(){" & vbCrLf & _ "if(Page_IsVali d){" & vbCrLf & _ "if(PageIsProce ssing==true){" & vbCrLf & _ "return false;" & vbCrLf & _ "}else{" & vbCrLf & _ "if(document.fo rms[0].btnNext != null){document. forms[0].btnNext.value = 'Processing...' ;}" & vbCrLf & _ "PageIsProcessi ng = true;" & vbCrLf & _ "return true;" & vbCrLf & _ "}" & vbCrLf & _ "}" & vbCrLf & _ "}" & vbCrLf & _ "</script>") End If
oPage.RegisterS tartupScript("P leaseWaitOnPost Back", "<script type='text/javascript'>" & vbCrLf & _ "var __doPostBack__ = window.__doPost Back;" & vbCrLf & _ "window.__doPos tBack = function(eventT arget, eventArgument) {" & vbCrLf & _ "if(PageIsProce ssing==true){" & vbCrLf & _ "}else{" & vbCrLf & _ "if(document.fo rms[0].btnNext != null){document. forms[0].btnNext.value = 'Processing...' ;}" & vbCrLf & _ "__doPostBack__ (eventTarget, eventArgument); " & vbCrLf & _ "PageIsProcessi ng = true;" & vbCrLf & _ "}" & vbCrLf & _ "}" & vbCrLf & _ "</script>") oPage.RegisterO nSubmitStatemen t("PleaseWait ", "if(!PleaseWait ()){return false};") End Function
============End Code=========== ======= This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bruno Alexandre |
last post by:
Hi guys,
If I want to block a user to change a form after submiting, I add a
function that will disable the submit button, but when I'm getting the form
collection (using post or get (form/querystring) I can't retrieve that
button value...
Is there any trick to do this?
Like https://www.cuworld.com/ webpage... Try to register as a free user
membership and after click the submit button check what hapend... They
|
by: Paul Oakfleet |
last post by:
The script below will disable Submit button until user accept terms,
and will redirect user to another page after clicking on Submit
button.
The script seems to work fine on my PC (Windows XP, IE6), however I
don't know if it's written well. I would like the opinion of someone
who knows how to write these codes properly. Please let me know if
there're any logic errors.
PS: Please keep in mind that I didn't write this script, I found it
|
by: techfuzz |
last post by:
I scoured this group and others looking for the best way to disable a
button after the first click to prevent multiple submissions, but
never did find anything that worked like they said it would. I went
ahead and wrote my own bit of code so I'm sharing it here for
everyone. Even though it doesn't really disable the button by greying
it out, it prevents the multiple submissions which it what I was
attempting to prevent all along. ...
|
by: Sinity |
last post by:
Anyone knows the method/codes to disable the clicked button after first
click by using .aspx-- to prevent people to click many time when waiting for
the server response.
I tried to do this by adding a java script for the button. But, useless..
Please help! Thank you
|
by: Jeff |
last post by:
I have a payment form with a submit button. A large percentage of users
double-click the submit button thus submitting their payment information
twice. I would like to use javascript to disable the submit button once
it's been clicked, yet still have the form submit. I can do this in ASP
2.0, however, ASP.Net seems to be adversely affected if you disable the
submit button. Here's how I have it set up...
The submit button is a...
| |
by: rodchar |
last post by:
hey all,
can someone please tell me if you can disable the scroll button for a
dropdownlist. For example, when you select an item in a dropdownlist and it
still has focus and you accidently hit scroll wheel on your mouse the
selected item changes.
can this be disabled?
thanks,
|
by: Barry Gilmore |
last post by:
Is there a way to disable a button after it is clicked?
I am trying to avoid having someone click on it twice while they wait for it
to process.
Thank you!
|
by: Sehboo |
last post by:
In my application, there are lot of processes which take several
seconds. What we want is that once user clicks on a button (or link or
whatever) and while we are processing that request, we don't want user
to do anything else on the page. We want to disable everything. I
have following javascript on all of my pages (which is supposed to
work), but it doesn't work.
<script language="JavaScript">
function ignoreinput() {
return false;
|
by: =?Utf-8?B?Unlhbg==?= |
last post by:
Hi,
I found out that Text property is perserved, but disable/enable status is
not preserved, especially I change this setting of a server side text box
with client side javascipt and then post back to server.
Is this a bug?
Thanks,
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |