Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CheckBox CheckedChanged Event Raised When Enabled Via Script

Status
Not open for further replies.

BDRichardson

Programmer
Jul 23, 2003
46
0
0
GB
Hi,

I am experiencing a strange problem with the CheckBox control. In summary, I am changing the 'disabled' state of the control with JavaScript in the client. The state is changed when I click on a different CheckBox. So, if the controlling CheckBox is Checked, then the controlled Checked is not disabled. And if the controlling CheckBox is not checked, then the controlled CheckBox is disabled.

When the controlling CheckBox is clicked, it calls a function, which appropriately changes the disabled state, and finally submits the page.

I am not using any server side code to control the either the disabled state, or the checked state.

However, my problem is that the checked state of the controlled CheckBox changes, and the CheckedChanged event is raised. I do not want this to happen when I click on the controlling CheckBox.

I have checked and confirmed the following:

EnableViewState property for the CheckBoxes is True.
AutoPostBack for the CheckBoxes is False.
Event Handlers are assigned correctly.

Does anyone know if the there is a bug related with the CheckBox control, and whether it is possible that either the Checked state is changed, or the CheckedChanged event is raised, whenever the disabled state is changed with client script?

I am using Visual Studio 2005 and Internet Explorer 7.
 
My problem definitely seems to be caused by changing the 'disabled' property within client script.

It would seem that if I change the disabled state, that the the Checked state of the CheckBox is changed.

Hence, resulting in the CheckedChanged event being raised.

:-(
 
It would also seem, that when the AutoPostBack property is set to True, and I assign a client side event handler, then a CheckBox will fail to post back.

As a consequence, to achieve a post back, I have to force it via client side script within the client side event handler.

:-(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top