473,399 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

disable button on click

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:

<script runat="server">
sub submit_it (Obj as Object, e as EventArgs)
if (Page.IsValid) then
BtnSubmit.text = Not(BtnSubmit.Enabled)
end if
End sub
</script>
Nov 18 '05 #1
7 1823
set a page-level variable , boolean boolAllow
then in ok click event

if boolAllow = true then
return
bAllow = true
btnOK.enable = false
DO YOUR STUFF HERE
btnok.enable = true ---- if u want
boolAllow = false

MIND - NOT REAL CODE ABOVE

bart
http://www.meshcode.net
"nicholas" <mu********@hotmail.com> wrote in message
news:eW*************@TK2MSFTNGP11.phx.gbl...
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:

<script runat="server">
sub submit_it (Obj as Object, e as EventArgs)
if (Page.IsValid) then
BtnSubmit.text = Not(BtnSubmit.Enabled)
end if
End sub
</script>

Nov 18 '05 #2
Nicholas,

This javascript will do the trick for you. It only disables the button if
the form passes validation:

<script language="javascript">
<!--
var submitcount=0;

function disableSubmit()
{
if (typeof(Page_ClientValidate)=='function')
{
if (Page_ClientValidate() == 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>

In VB.Net Attach it to your button like so:

SubmitButton.Attributes.Add("onClick", "javascript: return
disableSubmit();")
If you'd like I've encapsulated this script and a method for attaching it to
any button in a component I offer for free on my web site,
www.aboutfortunate.com.

Just go to the code library and then click the Javascript button in the menu
on the left. The entire component's source code is available (as a .Net
project) and it contains some other useful javascripts.
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"nicholas" <mu********@hotmail.com> wrote in message
news:eW*************@TK2MSFTNGP11.phx.gbl...
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:

<script runat="server">
sub submit_it (Obj as Object, e as EventArgs)
if (Page.IsValid) then
BtnSubmit.text = Not(BtnSubmit.Enabled)
end if
End sub
</script>

Nov 18 '05 #3

btnSubmit.enabled = False

hth,

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #4
Although I don't realy understand what you are trying to do, this is what I
tried without succes:

<script runat="server">
dim boolAllow as boolean
sub submit_it (Obj as Object, e as EventArgs)
if boolAllow = true then
return
boolAllow = true
BtnSubmit.enabled = false
boolAllow = false
if (Page.IsValid) then
BtnSubmit.enabled = False
end if
end if
End sub
</script>

"Infant Newbie" <ba**@remove.spam.meshcode.com> wrote in message
news:bq**********@news.freedom2surf.net...
set a page-level variable , boolean boolAllow
then in ok click event

if boolAllow = true then
return
bAllow = true
btnOK.enable = false
DO YOUR STUFF HERE
btnok.enable = true ---- if u want
boolAllow = false

MIND - NOT REAL CODE ABOVE

bart
http://www.meshcode.net
"nicholas" <mu********@hotmail.com> wrote in message
news:eW*************@TK2MSFTNGP11.phx.gbl...
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:

<script runat="server">
sub submit_it (Obj as Object, e as EventArgs)
if (Page.IsValid) then
BtnSubmit.text = Not(BtnSubmit.Enabled)
end if
End sub
</script>


Nov 18 '05 #5
That's what I tried first, but that does not work (although it doesn't
generate an error):

<script runat="server">
sub submit_it (Obj as Object, e as EventArgs)
BtnSubmit.enabled = false
End sub
</script>

"Kathy Burke" <ka**********@attbi.com> wrote in message
news:uZ**************@TK2MSFTNGP10.phx.gbl...

btnSubmit.enabled = False

hth,

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #6
if u still need help send me mail and i will send u a working example
ba**@no.spam.meshcode.com

http://www.meshcode.net
"nicholas" <mu********@hotmail.com> wrote in message
news:eH**************@TK2MSFTNGP09.phx.gbl...
Although I don't realy understand what you are trying to do, this is what I tried without succes:

<script runat="server">
dim boolAllow as boolean
sub submit_it (Obj as Object, e as EventArgs)
if boolAllow = true then
return
boolAllow = true
BtnSubmit.enabled = false
boolAllow = false
if (Page.IsValid) then
BtnSubmit.enabled = False
end if
end if
End sub
</script>

"Infant Newbie" <ba**@remove.spam.meshcode.com> wrote in message
news:bq**********@news.freedom2surf.net...
set a page-level variable , boolean boolAllow
then in ok click event

if boolAllow = true then
return
bAllow = true
btnOK.enable = false
DO YOUR STUFF HERE
btnok.enable = true ---- if u want
boolAllow = false

MIND - NOT REAL CODE ABOVE

bart
http://www.meshcode.net
"nicholas" <mu********@hotmail.com> wrote in message
news:eW*************@TK2MSFTNGP11.phx.gbl...
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:

<script runat="server">
sub submit_it (Obj as Object, e as EventArgs)
if (Page.IsValid) then
BtnSubmit.text = Not(BtnSubmit.Enabled)
end if
End sub
</script>



Nov 18 '05 #7
I tried to send you a mail, but your I got this error:
450 <ba**@no.spam.meshcode.com>: Recipient address rejected: Domain not
found

You'll find a mail link on my web site: www.squaresweb.com

Thanks a lot for your help.

"Infant Newbie" <ba**@remove.spam.meshcode.com> wrote in message
news:bq**********@news.freedom2surf.net...
if u still need help send me mail and i will send u a working example
ba**@no.spam.meshcode.com

http://www.meshcode.net
"nicholas" <mu********@hotmail.com> wrote in message
news:eH**************@TK2MSFTNGP09.phx.gbl...
Although I don't realy understand what you are trying to do, this is what
I
tried without succes:

<script runat="server">
dim boolAllow as boolean
sub submit_it (Obj as Object, e as EventArgs)
if boolAllow = true then
return
boolAllow = true
BtnSubmit.enabled = false
boolAllow = false
if (Page.IsValid) then
BtnSubmit.enabled = False
end if
end if
End sub
</script>

"Infant Newbie" <ba**@remove.spam.meshcode.com> wrote in message
news:bq**********@news.freedom2surf.net...
set a page-level variable , boolean boolAllow
then in ok click event

if boolAllow = true then
return
bAllow = true
btnOK.enable = false
DO YOUR STUFF HERE
btnok.enable = true ---- if u want
boolAllow = false

MIND - NOT REAL CODE ABOVE

bart
http://www.meshcode.net
"nicholas" <mu********@hotmail.com> wrote in message
news:eW*************@TK2MSFTNGP11.phx.gbl...
> 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:
>
> <script runat="server">
> sub submit_it (Obj as Object, e as EventArgs)
> if (Page.IsValid) then
> BtnSubmit.text = Not(BtnSubmit.Enabled)
> end if
> End sub
> </script>
>
>



Nov 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
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...
1
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...
2
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. ...
14
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...
3
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...
0
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...
16
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!
4
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...
0
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...
8
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I disable the right mouse button? -----------------------------------------------------------------------...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
jinu1996
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...
0
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...
0
tracyyun
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...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.