happyslug

happyslug

  • NA
  • 11
  • 0

Checkbox being changed in Javascript not reflected in C#

Oct 5 2011 9:55 AM
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)