2
Answers

Checkbox being changed in Javascript not reflected in C#

happyslug

happyslug

13y
1.3k
1
I have a checkbox which I change the checked via Javascript

var check = document.getElementById('chk1');
check.checked = false;

This works as far as the screen goes.

However, if i then tick it via the UI, the Checkchanged event which does get called.

BUT, when in the Checkchanged event, if I look at chk1.checked, it is as it was prior to the javascript.



So for example, on screen the checkbox is unticked.

I click on it (to tick it) - the checkchange event says that chk1.checked is checked - so thats correct.

I then run Javascript as above, on screen it is now unticked.

I then click it on screen - the checkchange event now sats that chk1.checked is not ticked - even though on screen it is.

Answers (2)