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 14 7187
Using Javascript(Clie nt side
You can add a javascript onclick handler in the .cs file as unde
string x = "document.Form1 .Button1.disabl ed=true"
this.Button1.At tributes.Add("o nclick",x)
To do the same on the server side
add the following to your button click event handler { i.e the function --private void Button1_Click(o bject sender, System.EventArg s e)
this.Button1.En abled=false
Sinity,
I'm just about to post the code to do this on my website, but here you go:
It stops the submit, but even better it calls some of the same .Net client
side code and doesn't disable the button if any required field validators
aren't valid and the page doesn't actually submit.
<script language="javas cript">
<!--
var submitcount=0;
function disableSubmit()
{
if (typeof(Page_Cl ientValidate)== 'function')
{
if (Page_ClientVal idate() == true)
{
return checkSubmit();
}
else
{
return true;
}
}
else
{
return checkSubmit();
}
}
function checkSubmit()
{
if (submitcount == 0)
{
submitcount++; return true;
}
else
{
alert('This form has already been submitted.'); return false;
}
}
//-->
</script>
Attach it to your button like so:
SubmitButton.At tributes.Add("o nClick", "javascript : return
disableSubmit() ;")
Sincerely,
--
S. Justin Gengo, MCP
Web Developer
Free code library at: www.aboutfortunate.com
"Out of chaos comes order."
Nietzche
"Sinity" <si****@msn.com > wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. 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
> if (Page_ClientVal idate() == true) { return checkSubmit(); } else { return true; <<< ----- You mean return false; right? }
Homa Wong
"S. Justin Gengo" <sj*****@aboutf ortunate.com> wrote in message news:<ud******* *******@TK2MSFT NGP10.phx.gbl>. .. Sinity,
I'm just about to post the code to do this on my website, but here you go:
It stops the submit, but even better it calls some of the same .Net client side code and doesn't disable the button if any required field validators aren't valid and the page doesn't actually submit.
<script language="javas cript"> <!-- var submitcount=0;
function disableSubmit() { if (typeof(Page_Cl ientValidate)== 'function') { if (Page_ClientVal idate() == true) { return checkSubmit(); } else { return true; } } else { return checkSubmit(); } }
function checkSubmit() { if (submitcount == 0) { submitcount++; return true; } else { alert('This form has already been submitted.'); return false; } } //--> </script>
Attach it to your button like so:
SubmitButton.At tributes.Add("o nClick", "javascript : return disableSubmit() ;")
Sincerely,
-- S. Justin Gengo, MCP Web Developer
Free code library at: www.aboutfortunate.com
"Out of chaos comes order." Nietzche
"Sinity" <si****@msn.com > wrote in message news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. 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
As the server response is slow something because of the network traffic,
users click again and again.
how can I manage this problem in aspx level?
I am using VB.NET as the devevelopment tool
"S. Justin Gengo" <sj*****@aboutf ortunate.com> ¼¶¼g©ó¶l¥ó·s»D
:ud************ **@TK2MSFTNGP10 .phx.gbl... Sinity,
I'm just about to post the code to do this on my website, but here you go:
It stops the submit, but even better it calls some of the same .Net client side code and doesn't disable the button if any required field validators aren't valid and the page doesn't actually submit.
<script language="javas cript"> <!-- var submitcount=0;
function disableSubmit() { if (typeof(Page_Cl ientValidate)== 'function') { if (Page_ClientVal idate() == true) { return checkSubmit(); } else { return true; } } else { return checkSubmit(); } }
function checkSubmit() { if (submitcount == 0) { submitcount++; return true; } else { alert('This form has already been submitted.'); return false; } } //--> </script>
Attach it to your button like so:
SubmitButton.At tributes.Add("o nClick", "javascript : return disableSubmit() ;")
Sincerely,
-- S. Justin Gengo, MCP Web Developer
Free code library at: www.aboutfortunate.com
"Out of chaos comes order." Nietzche
"Sinity" <si****@msn.com > wrote in message news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. 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
If IsPostBack Then
button.enabled = false
End If
"Sinity" <si****@msn.com > wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. 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
No, "return false;" is correct. Try it out.
Sincerely,
--
S. Justin Gengo, MCP
Web Developer
Free code library at: www.aboutfortunate.com
"Out of chaos comes order."
Nietzche
"Homa" <ho******@yahoo .com> wrote in message
news:a9******** *************** ***@posting.goo gle.com... if (Page_ClientVal idate() == true) { return checkSubmit(); } else { return true; <<< ----- You mean return false; right? }
Homa Wong
"S. Justin Gengo" <sj*****@aboutf ortunate.com> wrote in message
news:<ud******* *******@TK2MSFT NGP10.phx.gbl>. .. Sinity,
I'm just about to post the code to do this on my website, but here you
go: It stops the submit, but even better it calls some of the same .Net
client side code and doesn't disable the button if any required field
validators aren't valid and the page doesn't actually submit.
<script language="javas cript"> <!-- var submitcount=0;
function disableSubmit() { if (typeof(Page_Cl ientValidate)== 'function') { if (Page_ClientVal idate() == true) { return checkSubmit(); } else { return true; } } else { return checkSubmit(); } }
function checkSubmit() { if (submitcount == 0) { submitcount++; return true; } else { alert('This form has already been submitted.'); return false; } } //--> </script>
Attach it to your button like so:
SubmitButton.At tributes.Add("o nClick", "javascript : return disableSubmit() ;")
Sincerely,
-- S. Justin Gengo, MCP Web Developer
Free code library at: www.aboutfortunate.com
"Out of chaos comes order." Nietzche
"Sinity" <si****@msn.com > wrote in message news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. 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
?? But I thought you wrote "return true" ??
Homa Wong
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Homa,
Now I've confused myself! Yes, it has to be "return true;".
This is because the submit button's click event fires off two different
asp.net javascripts. One is the javascript I'm tying into:
Page_ClientVali date, the other is a javascript that checks the required
field validators.
At the point in question inside of my javascript if the Button doesn't get
clicked (which is what "return false;" would cause then any validators on
the page wouldn't get displayed properly.
Sincerely,
--
S. Justin Gengo, MCP
Web Developer
Free code library at: www.aboutfortunate.com
"Out of chaos comes order."
Nietzche
"Homa Wong" <no*****@MyWorl d.com> wrote in message
news:eN******** ******@TK2MSFTN GP09.phx.gbl... ?? But I thought you wrote "return true" ??
Homa Wong
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
haha,
...."Out of chaos comes order."
Homa Wong
"S. Justin Gengo" <sj*****@aboutf ortunate.com> wrote in message news:<u6******* *******@TK2MSFT NGP11.phx.gbl>. .. Homa,
Now I've confused myself! Yes, it has to be "return true;".
This is because the submit button's click event fires off two different asp.net javascripts. One is the javascript I'm tying into: Page_ClientVali date, the other is a javascript that checks the required field validators.
At the point in question inside of my javascript if the Button doesn't get clicked (which is what "return false;" would cause then any validators on the page wouldn't get displayed properly.
Sincerely,
-- S. Justin Gengo, MCP Web Developer
Free code library at: www.aboutfortunate.com
"Out of chaos comes order." Nietzche
"Homa Wong" <no*****@MyWorl d.com> wrote in message news:eN******** ******@TK2MSFTN GP09.phx.gbl... ?? But I thought you wrote "return true" ??
Homa Wong
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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!
|
by: lori3laz |
last post by:
How do you disable the right click>view source option on web pages so people
can't view your coding and copy it? What's the html I need to include in my
website to utilize this feature?
Thank you.
|
by: nicholas |
last post by:
how can I disable a button when the user clicks on it and the webform is
validated.
I want this to prevent the user from clicking twice and by this submitting
the form twice.
Thank you.
This is what I tried, but it does nothing:
|
by: Earl Teigrob |
last post by:
PROBLEM:
When a user control is loaded into a PlaceHolder control more than once, the
events do not fire on the first click of a control on the dynamically loaded
user control. In other words, the first time the control is dynamically
loaded, everything works fine. After that, if the control is loaded again
from the page button event handler, the user controls events fail to fire on
the first click
NOTE: I (believe I) am rebuilding all...
|
by: Tee |
last post by:
Hi,
I have a server side Button that with the code
Button3.Attributes.Add("onclick",
"javascript:document.all.disabled=True; return false;")
but it don't work as it supposed to be, disable button and the return false
prevent it submit back to server.
| |
by: megan_c |
last post by:
Hi,
I have several check boxes on a form which are bound to a database record.
I'm having an issue with one of them.
After loading and binding the controls, i disable and enable this one(I'll
call it chkbox2) based on another check box value(call this one chkbox1).
However, on the first click after enabling chkbox2, it is not being checked.
After the first click it starts working properly.....any ideas?????
|
by: Buddy Ackerman |
last post by:
If I put client side code to disable a button (so that a user doesn't click
it twice and double post the form) then teh button doesn't get posted with
the form and the button's server-side click event handler is not fired.
Seems like a big hole in the ASP.NET form handling process. Any way around
it and still use the button click event handler?
--Buddy
|
by: user |
last post by:
Hello,
With ASP.NET2, how to program a button's click ?
For example, I have two button and when i click the first one, i would like
that the second one will be click too (by programming) ... something like
button2.click ???
Thanks for help ..
|
by: William |
last post by:
Hi
I've created a page with only 'n blank table control on it. When clicking a
button, the table populates with various textboxes and dropdown lists to
make up a complete form. In the last row of the table, a submit button is
added.
Almost everything works fine. The form display, the user fills out the form
and then click Submit. However, the first time the submit button is
clicked, the Click event isn't raised. Just a simple...
|
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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.
| |