Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 10th, 2011, 04:32 PM
Authorized User
 
Join Date: Jan 2011
Posts: 89
Thanks: 1
Thanked 0 Times in 0 Posts
Default Disabling buttons after click

I'm guessing Javascript is the best way to do this because I need to disable a button to stop multiple post backs. I have added the following function:

Code:
<script type="text/javascript">
    function disablebutton() {
        document.getElementById("LoginButton").disabled = true;
    }
</script>
and added to my ASP button:

OnClientClick="disablebutton()"

Problem is I get the following error:
Microsoft JScript runtime error: Unable to set value of the property 'disabled': object is null or undefined

Can anyone help?
 
Old November 10th, 2011, 05:10 PM
Authorized User
 
Join Date: Jan 2011
Posts: 89
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I used the following which seems to work ok:

OnClientClick="this.disabled = true" UseSubmitBehavior="false"
 
Old November 10th, 2011, 05:26 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Check the actual id of the button, it's probably not what you think.
If you are using asp 4 you can set it precisely.
__________________
Joe
http://joe.fawcett.name/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Disabling CheckBoxList Edkch BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 September 7th, 2011 12:20 PM
Disabling texbox based on the selection of 4 radio buttons nepal ASP.NET 1.0 and 1.1 Professional 1 April 1st, 2009 05:35 PM
Right-Click or Double-Click Combobox? panuvin C# 2005 3 June 15th, 2006 04:30 PM
Roll-over buttons with simple "click" sound? larry HTML Code Clinic 1 December 29th, 2003 07:29 PM
Is there any way of disabling logging? chrislepingwell SQL Server 2000 1 October 9th, 2003 11:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.