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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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").disabled = 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").disabled = true
window.document.getElementbyId("btnDisable").disabled = false
The click event is also fired
Do somebody know why

Bin Song, MCP
 
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 said:
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").disabled = false;
window.document.getElementbyId("btnDisable").value = "Enable";
}

Then the strangest thing happens. The server-side click event of
btnDisable is not fired after clicking.
 
Back
Top