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! 16 3455
Hi Barry,
This should work:
Button1.Attribu te.Add("onclick ", "this.disab led = true;
document.Form1. submit(); return false;")
I didn't test it but I know you need to submit the form yourself and cancle
the event bubble on the submit button. Good luck! Ken.
--
Ken Dopierala Jr.
For great ASP.Net web hosting try: http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.
"Barry Gilmore" <no**********@y ahoo.com> wrote in message
news:ro******** ******@tornado. rdc-kc.rr.com... 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!
adding following code in the onClick event (javascript), will stop the user
from pressing it again
document.getEle mentById('butto nname').disable d='true';
"Barry Gilmore" wrote: 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!
Barry,
I have a javascript that first makes a call to .net's built in
authentication scripts to make certain a form is submittable (you wouldn't
want to disable a button if the clientside script decides it's not valid and
doesn't submit thus stranding the user) and then disables a second click of
said button.
The code is available as part of a Javascript component that is free for
download from my website as a Visual Studio.Net 2003 project. Even if you
don't want to use the whole component (it has other scripts such as open a
centered popup window, click a button when the enter key is pressed while in
a text box, scroll to an element on the page, etc.) you could always strip
out the code you want. All the components on my site are free, all come with
complete source code, and there is a help file you may download if you'd
like.
You may download the component from here: http://www.aboutfortunate.com?page=javascript
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"Barry Gilmore" <no**********@y ahoo.com> wrote in message
news:ro******** ******@tornado. rdc-kc.rr.com... 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!
Ken,
That will work, but what if the form isn't valid. Now the user can't fix and
resubmit...
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"Ken Dopierala Jr." <kd*********@wi .rr.com> wrote in message
news:uF******** *****@tk2msftng p13.phx.gbl... Hi Barry,
This should work:
Button1.Attribu te.Add("onclick ", "this.disab led = true; document.Form1. submit(); return false;")
I didn't test it but I know you need to submit the form yourself and cancle the event bubble on the submit button. Good luck! Ken.
-- Ken Dopierala Jr. For great ASP.Net web hosting try: http://www.webhost4life.com/default.asp?refid=Spinlight If you sign up under me and need help, email me.
"Barry Gilmore" <no**********@y ahoo.com> wrote in message news:ro******** ******@tornado. rdc-kc.rr.com... 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!
Why using javascript?
It can be done very simply by C# code...
private void Button1_Click(o bject sender, System.EventArg s e)
{
Button1.Enabled = false;
}
Bishoy
-------
"Barry Gilmore" <no**********@y ahoo.com> wrote in message
news:ro******** ******@tornado. rdc-kc.rr.com... 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!
Bishoy George wrote: Why using javascript? It can be done very simply by C# code...
private void Button1_Click(o bject sender, System.EventArg s e) { Button1.Enabled = false; }
I think what he's trying to do is prevent someone from submitting a form
twice. Doing that in server-side code wouldn't not work.
--
Jim Cheshire
JIMCO Software http://www.jimcosoftware.com
"JIMCO Software" <co*******@jimc osoftware.com> wrote in message
news:uP******** ******@TK2MSFTN GP14.phx.gbl... Bishoy George wrote: Why using javascript? It can be done very simply by C# code...
private void Button1_Click(o bject sender, System.EventArg s e) { Button1.Enabled = false; }
I think what he's trying to do is prevent someone from submitting a form twice. Doing that in server-side code wouldn't not work.
-- Jim Cheshire JIMCO Software http://www.jimcosoftware.com
--------------------------------------------------------------
It is working with me.
I think if you revised what Mr.Barry Gilmore wanted, you may find my code
efficient.
Bishoy http://bishoy.com
Bishoy George wrote: It is working with me. I think if you revised what Mr.Barry Gilmore wanted, you may find my code efficient.
Bishoy,
If you set the Enabled property of the button in server-side code, it only
affects the button when the page is rendered AFTER the postback. That won't
prevent someone from clicking the Submit button twice on a form. In order
to do that, you need to disable the button on the client immediately after
the form is submitted but before it actually POSTs.
Your code will not meet that need.
--
Jim Cheshire
JIMCO Software http://www.jimcosoftware.com
I tried the code submitted by Ken Dopierala Jr.
It disable the button for a second then when the page is refreshed due to
post back, it is enabled again.
Also the code of Sreejith Ram is not working.
Bishoy http://bishoy.com
-----------------------------------------------------
"Barry Gilmore" <no**********@y ahoo.com> wrote in message
news:ro******** ******@tornado. rdc-kc.rr.com... 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!
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: nntp |
last post by:
I have a set of links which I want search engines to crawl them, but I want
to disable them from my visitors, so I will ask the link owners to pay me to
let me enable them.
<a disabled href="#">bahbahbah</a>
Does not work, as it is still clickable. It only changes the color to grey.
|
by: Suni |
last post by:
Hi everybody,
But what I am trying to do is like, there are 2 forms, and if I click on the
button in form1, it'll open up form2 and disable the button in form1. Then
when I click on the button in form2, it will close form2, and then enable
the button in form1. Could you please give me some hints about this?
Thanks,
Suni
|
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: Robert Ladd |
last post by:
Hi,
I'm trying to disable the asp.net calendar control from a javascript
function, but it doesn't disable the doPostBack.
To simplify the situation, assume a page with 4 controls. A dropdownlist, a
calendar control, a textbox and an update button. What I'm doing is
initially setting the button to disabled, the other 3 controls are enabled.
If any data is entered in the textbox, I want to disable the dropdownlist
and the calendar...
|
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: Ahmad Jalil Qarshi |
last post by:
Hi!
I have a problem while developing some webpages.The Problem is that:-
How We Can Disable The Controls Of One Web Form From Other Web Form In
Asp.net?
Explanation:-
There Should Be Two Web Form,Web Form1.aspx and Web Form2.aspx,Now From Web
Form1.aspx When I Click One Button (Disable), Then Web Form2.aspx Buttons
|
by: FAQ server |
last post by:
-----------------------------------------------------------------------
FAQ Topic - How do I disable the right mouse button?
-----------------------------------------------------------------------
The oncontextmenu intrinsic event is the only safe and reliable
method. Of the other approaches often presented, most depend on
an alert box interrupting the process and rarely work. Note that
oncontextmenu is a non-standard event and is not...
|
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: 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: 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: 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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |