473,386 Members | 1,841 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,386 software developers and data experts.

Button disabled and re-enabled in client side not firing server-side click event.

Hi all

I got a strange problem
In my webform, I have a server-side Button "btnDisable" to save some data and enable or disable all other fields in this form based on the data.
The logic is: on server click event, save data, write a client-side script to set 'ynDisable' to true or false, and then use general client-side code in window's onload event to disable all fields. The code is
function disableFields(

with (window.document

var iDocLen = all.length
for(var i = 0; i < iDocLen; i++

all(i).disabled = true

This code also disabled the Button "btnDisable". So I add one line of code to enable it
if (yndisable == true

disableFields()
window.document.getElementbyId("btnDisable").disab led = false
window.document.getElementbyId("btnDisable").value = "Enable"
Then the strangest thing happens. The server-side click event of btnDisable is not fired after clicking
In testing, if I don't call disableFields function, the event is fired
Or if I change to the following code
window.document.getElementbyId("btnDisable").disab led = true
window.document.getElementbyId("btnDisable").disab led = false
The click event is also fired
Do somebody know why

Bin Song, MCP
Nov 18 '05 #1
1 2886
browsers do not postback any values for disabled input controls. if you
disable the button, its value will not be posted, and the server has no way
of knowing the button was clicked.

-- bruce (sqlwork.com)

"Bin Song, MCP" <an*******@discussions.microsoft.com> wrote in message
news:AD**********************************@microsof t.com...
Hi all,

I got a strange problem.
In my webform, I have a server-side Button "btnDisable" to save some data and enable or disable all other fields in this form based on the data. The logic is: on server click event, save data, write a client-side script to set 'ynDisable' to true or false, and then use general client-side code
in window's onload event to disable all fields. The code is: function disableFields()
{
with (window.document)
{
var iDocLen = all.length;
for(var i = 0; i < iDocLen; i++)
{
all(i).disabled = true;
}
}
}
This code also disabled the Button "btnDisable". So I add one line of code to enable it. if (yndisable == true)
{
disableFields();
window.document.getElementbyId("btnDisable").disab led = false;
window.document.getElementbyId("btnDisable").value = "Enable";
}

Then the strangest thing happens. The server-side click event of btnDisable is not fired after clicking. In testing, if I don't call disableFields function, the event is fired.
Or if I change to the following code:
window.document.getElementbyId("btnDisable").disab led = true;
window.document.getElementbyId("btnDisable").disab led = false;
The click event is also fired.
Do somebody know why?

Bin Song, MCP

Nov 18 '05 #2

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

Similar topics

5
by: bart plessers | last post by:
Hello, Somewhere in my code I have <input TYPE="button" NAME="btnFirst" VALUE="<<" OnClick="GetFile('1')" DISABLED> I changed the layout of the INPUT with a stylesheet to INPUT { color:...
0
by: bart plessers | last post by:
Hello, Somewhere in my code I have <input TYPE="button" NAME="btnFirst" VALUE="<<" OnClick="GetFile('1')" DISABLED> I changed the layout of the INPUT with a stylesheet to INPUT { color:...
0
by: caraweb | last post by:
Good Morning, im searching for this result since half a day! I've got a Button which has the class=head. The Styles looks like that: input.head{ background: none #225A8D; color: #FFFFFF;...
22
by: Papajo | last post by:
This simple script counts up or down with a button click, now can it be modified so the count won't go below zero?            Thanks, Joe <form> <input type=text name=amount size=4 value=>...
2
by: Sveta | last post by:
Hi all! C# question: Does anyone knows how to make a toolbar button image to make visible for a disabled button? When the toolbar button is disabled, only the gray hole is displayed instead...
2
by: Zytan | last post by:
If you have a disabled button in a form (or tabpage) whose background color is customized, the text on the disabled button will not be gray. In fact, it becomes a *brighter* version of the...
3
by: orita | last post by:
Hello all, I need heeeeeeeeeeeeeeeelp... how can I enable/disable a few text box after clicking a radio button? I found this code in this site but it's only refer to one text feild and I...
1
by: arggg | last post by:
I created a submit form that calls a javascript:AjAX Command that will call the data and submit it without have the page refresh. This works perfect in Firefox however in IE and Opera when the...
2
by: labmonkey111 | last post by:
I have a form that takes several seconds to run the javascript needed to prepare the form for PHP (selecting all items in a Select Multiple). Since it takes so long, I want to disable the Submit...
10
by: sowmyati | last post by:
HI All, I am new to javascript. I have snippet wherein i am giving a brief note on what i am trying to do. In the below have a variable by name stuff. trying to reset the page. Part of the code...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.